Class Query (2.14.0)

public final class Query implements Serializable

A simple wrapper to construct a query for the ReadRows RPC.

Inheritance

Object > Query

Implements

Serializable

Static Methods

create(String tableId)

public static Query create(String tableId)

Constructs a new Query object for the specified table id. The table id will be combined with the instance name specified in the com.google.cloud.bigtable.data.v2.BigtableDataSettings.

Parameter
NameDescription
tableIdString
Returns
TypeDescription
Query

fromProto(ReadRowsRequest request)

public static Query fromProto(ReadRowsRequest request)

Wraps the protobuf ReadRowsRequest.

WARNING: Please note that the project id & instance id in the table name will be overwritten by the configuration in the BigtableDataClient.

Parameter
NameDescription
requestReadRowsRequest
Returns
TypeDescription
Query

Methods

clone()

public Query clone()
Returns
TypeDescription
Query
Overrides

equals(Object o)

public boolean equals(Object o)
Parameter
NameDescription
oObject
Returns
TypeDescription
boolean
Overrides

filter(Filters.Filter filter)

public Query filter(Filters.Filter filter)

Sets the filter to apply to each row. Only one filter can be set at a time. To use multiple filters, please use Filters#interleave() or Filters#chain().

Parameter
NameDescription
filterFilters.Filter
Returns
TypeDescription
Query

getBound()

public Range.ByteStringRange getBound()

Get the minimal range that encloses all of the row keys and ranges in this Query.

Returns
TypeDescription
Range.ByteStringRange

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

limit(long limit)

public Query limit(long limit)

Limits the number of rows that can be returned

Parameter
NameDescription
limitlong
Returns
TypeDescription
Query

prefix(ByteString prefix)

public Query prefix(ByteString prefix)
Parameter
NameDescription
prefixByteString
Returns
TypeDescription
Query

prefix(String prefix)

public Query prefix(String prefix)
Parameter
NameDescription
prefixString
Returns
TypeDescription
Query

range(Range.ByteStringRange range)

public Query range(Range.ByteStringRange range)

Adds a range to be looked up.

Parameter
NameDescription
rangeRange.ByteStringRange
Returns
TypeDescription
Query

range(ByteString start, ByteString end)

public Query range(ByteString start, ByteString end)

Adds a range to be looked up.

Parameters
NameDescription
startByteString

The beginning of the range (inclusive). Can be null to represent negative infinity.

endByteString

The end of the range (exclusive). Can be null to represent positive infinity.

Returns
TypeDescription
Query

range(String start, String end)

public Query range(String start, String end)

Adds a range to be looked up.

Parameters
NameDescription
startString

The beginning of the range (inclusive). Can be null to represent negative infinity.

endString

The end of the range (exclusive). Can be null to represent positive infinity.

Returns
TypeDescription
Query

rowKey(ByteString key)

public Query rowKey(ByteString key)

Adds a key to looked up

Parameter
NameDescription
keyByteString
Returns
TypeDescription
Query

rowKey(String key)

public Query rowKey(String key)

Adds a key to looked up

Parameter
NameDescription
keyString
Returns
TypeDescription
Query

shard(List<KeyOffset> sampledRowKeys)

public List<Query> shard(List<KeyOffset> sampledRowKeys)

Split this query into multiple queries that can be evenly distributed across Bigtable nodes and be run in parallel. This method takes the results from com.google.cloud.bigtable.data.v2.BigtableDataClient#sampleRowKeysAsync(String) to divide this query into a set of disjoint queries that logically combine into form this query.

Expected Usage:


 List<KeyOffset> keyOffsets = dataClient.sampleRowKeysAsync("my-table").get();
 List<Query> queryShards = myQuery.shard(keyOffsets);
 List
Parameter
NameDescription
sampledRowKeysList<KeyOffset>
Returns
TypeDescription
List<Query>

shard(SortedSet<ByteString> splitPoints)

public List<Query> shard(SortedSet<ByteString> splitPoints)

Split this query into multiple queries that logically combine into this query. This is intended to be used by map reduce style frameworks like Beam to split a query across multiple workers.

Expected Usage:


 List<ByteString> splitPoints = ...;
 List<Query> queryShards = myQuery.shard(splitPoints);
 List
Parameter
NameDescription
splitPointsSortedSet<ByteString>
Returns
TypeDescription
List<Query>

toProto(RequestContext requestContext)

public ReadRowsRequest toProto(RequestContext requestContext)

Creates the request protobuf. This method is considered an internal implementation detail and not meant to be used by applications.

Parameter
NameDescription
requestContextcom.google.cloud.bigtable.data.v2.internal.RequestContext
Returns
TypeDescription
ReadRowsRequest

toString()

public String toString()
Returns
TypeDescription
String
Overrides