Class Query
java.lang.Object
com.google.cloud.bigtable.data.v2.models.Query
- All Implemented Interfaces:
Serializable
A simple wrapper to construct a query for the ReadRows RPC.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A Query Paginator that will split a query into small chunks. -
Method Summary
Modifier and TypeMethodDescriptionclone()
static Query
Constructs a new Query object for the specified table id.createPaginator
(int pageSize) Create a query paginator that'll split the query into smaller chunks.boolean
filter
(Filters.Filter filter) Sets the filter to apply to each row.static Query
fromProto
(com.google.bigtable.v2.ReadRowsRequest request) Wraps the protobufReadRowsRequest
.getBound()
Get the minimal range that encloses all of the row keys and ranges in this Query.int
hashCode()
limit
(long limit) Limits the number of rows that can be returnedprefix
(com.google.protobuf.ByteString prefix) range
(Range.ByteStringRange range) Adds a range to be looked up.range
(com.google.protobuf.ByteString start, com.google.protobuf.ByteString end) Adds a range to be looked up.Adds a range to be looked up.reversed
(boolean enable) Return rows in reverse order.rowKey
(com.google.protobuf.ByteString key) Adds a key to looked upAdds a key to looked upSplit this query into multiple queries that can be evenly distributed across Bigtable nodes and be run in parallel.Split this query into multiple queries that logically combine into this query.com.google.bigtable.v2.ReadRowsRequest
toProto
(com.google.cloud.bigtable.data.v2.internal.RequestContext requestContext) Creates the request protobuf.toString()
-
Method Details
-
create
Constructs a new Query object for the specified table id. The table id will be combined with the instance name specified in theBigtableDataSettings
. -
rowKey
Adds a key to looked up -
rowKey
Adds a key to looked up -
prefix
-
prefix
-
range
Adds a range to be looked up.- Parameters:
start
- The beginning of the range (inclusive). Can be null to represent negative infinity.end
- The end of the range (exclusive). Can be null to represent positive infinity.
-
range
Adds a range to be looked up.- Parameters:
start
- The beginning of the range (inclusive). Can be null to represent negative infinity.end
- The end of the range (exclusive). Can be null to represent positive infinity.
-
range
Adds a range to be looked up. -
filter
Sets the filter to apply to each row. Only one filter can be set at a time. To use multiple filters, please useFilters.interleave()
orFilters.chain()
. -
limit
Limits the number of rows that can be returned -
reversed
Return rows in reverse order.The row will be streamed in reverse lexiographic order of the keys. The row key ranges are still expected to be oriented the same way as forwards. ie [a,c] where a <= c. The row content will remain unchanged from the ordering forward scans. This is particularly useful to get the last N records before a key:
query .range(ByteStringRange.unbounded().endOpen("key")) .limit(10) .reversed(true)
-
shard
Split this query into multiple queries that can be evenly distributed across Bigtable nodes and be run in parallel. This method takes the results fromBigtableDataClient.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<ApiFuture<List<Row>>> futures = new ArrayList(); for (Query subQuery : queryShards) { futures.add(dataClient.readRowsCallable().all().futureCall(subQuery)); } List<List<Row>> results = ApiFutures.allAsList(futures).get();
-
shard
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<ApiFuture<List<Row>>> futures = new ArrayList(); for (Query subQuery : queryShards) { futures.add(dataClient.readRowsCallable().all().futureCall(subQuery)); } List<List<Row>> results = ApiFutures.allAsList(futures).get();
-
createPaginator
@BetaApi("This surface is stable yet it might be removed in the future.") 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));
-
getBound
Get the minimal range that encloses all of the row keys and ranges in this Query. -
toProto
@InternalApi public com.google.bigtable.v2.ReadRowsRequest toProto(com.google.cloud.bigtable.data.v2.internal.RequestContext requestContext) Creates the request protobuf. This method is considered an internal implementation detail and not meant to be used by applications. -
fromProto
Wraps the protobufReadRowsRequest
.WARNING: Please note that the project id & instance id in the table name will be overwritten by the configuration in the BigtableDataClient.
-
clone
-
equals
-
hashCode
public int hashCode() -
toString
-