public final class Query implements Serializable
A simple wrapper to construct a query for the ReadRows RPC.
Static Methods
create(String tableId)
public static Query create(String tableId)
Parameter |
---|
Name | Description |
tableId | String
|
Returns |
---|
Type | Description |
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 |
---|
Name | Description |
request | com.google.bigtable.v2.ReadRowsRequest
|
Returns |
---|
Type | Description |
Query | |
Methods
clone()
Returns |
---|
Type | Description |
Query | |
Overrides
createPaginator(int pageSize)
public Query.QueryPaginator createPaginator(int pageSize)
Create a query paginator that'll split the query into smaller chunks.
Example usage:
Query query = Query.create(...).range("a", "z");
Query.QueryPaginator paginator = query.createQueryPaginator(100);
ByteString lastSeenRowKey = ByteString.EMPTY;
do {
List<Row> rows = client.readRowsCallable().all().call(paginator.getNextQuery());
for (Row row : rows) {
// do some processing
lastSeenRow = row;
}
} while (paginator.advance(lastSeenRowKey));
Parameter |
---|
Name | Description |
pageSize | int
|
equals(Object o)
public boolean equals(Object o)
Parameter |
---|
Name | Description |
o | Object
|
Overrides
filter(Filters.Filter filter)
public Query filter(Filters.Filter filter)
Returns |
---|
Type | Description |
Query | |
getBound()
public Range.ByteStringRange getBound()
Get the minimal range that encloses all of the row keys and ranges in this Query.
hashCode()
Returns |
---|
Type | Description |
int | |
Overrides
limit(long limit)
public Query limit(long limit)
Limits the number of rows that can be returned
Parameter |
---|
Name | Description |
limit | long
|
Returns |
---|
Type | Description |
Query | |
prefix(ByteString prefix)
public Query prefix(ByteString prefix)
Returns |
---|
Type | Description |
Query | |
prefix(String prefix)
public Query prefix(String prefix)
Parameter |
---|
Name | Description |
prefix | String
|
Returns |
---|
Type | Description |
Query | |
range(Range.ByteStringRange range)
public Query range(Range.ByteStringRange range)
Adds a range to be looked up.
Returns |
---|
Type | Description |
Query | |
range(ByteString start, ByteString end)
public Query range(ByteString start, ByteString end)
Adds a range to be looked up.
Parameters |
---|
Name | Description |
start | ByteString
The beginning of the range (inclusive). Can be null to represent negative
infinity.
|
end | ByteString
The end of the range (exclusive). Can be null to represent positive infinity.
|
Returns |
---|
Type | Description |
Query | |
range(String start, String end)
public Query range(String start, String end)
Adds a range to be looked up.
Parameters |
---|
Name | Description |
start | String
The beginning of the range (inclusive). Can be null to represent negative
infinity.
|
end | String
The end of the range (exclusive). Can be null to represent positive infinity.
|
Returns |
---|
Type | Description |
Query | |
rowKey(ByteString key)
public Query rowKey(ByteString key)
Returns |
---|
Type | Description |
Query | |
rowKey(String key)
public Query rowKey(String key)
Parameter |
---|
Name | Description |
key | String
|
Returns |
---|
Type | Description |
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
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
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 |
---|
Name | Description |
requestContext | com.google.cloud.bigtable.data.v2.internal.RequestContext
|
Returns |
---|
Type | Description |
com.google.bigtable.v2.ReadRowsRequest | |
toString()
Overrides