public final class Query extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
static Query |
create(String tableId)
Constructs a new Query object for the specified table id.
|
boolean |
equals(Object o) |
Query |
filter(Filters.Filter filter)
Sets the filter to apply to each row.
|
static Query |
fromProto(ReadRowsRequest request)
Wraps the protobuf
ReadRowsRequest . |
Range.ByteStringRange |
getBound()
Get the minimal range that encloses all of the row keys and ranges in this Query.
|
int |
hashCode() |
Query |
limit(long limit)
Limits the number of rows that can be returned
|
Query |
prefix(ByteString prefix) |
Query |
prefix(String prefix) |
Query |
range(ByteString start,
ByteString end)
Adds a range to be looked up.
|
Query |
range(Range.ByteStringRange range)
Adds a range to be looked up.
|
Query |
range(String start,
String end)
Adds a range to be looked up.
|
Query |
rowKey(ByteString key)
Adds a key to looked up
|
Query |
rowKey(String key)
Adds a key to looked up
|
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.
|
List<Query> |
shard(SortedSet<ByteString> splitPoints)
Split this query into multiple queries that logically combine into this query.
|
ReadRowsRequest |
toProto(com.google.cloud.bigtable.data.v2.internal.RequestContext requestContext)
Creates the request protobuf.
|
String |
toString() |
public static Query create(String tableId)
BigtableDataSettings
.public Query rowKey(ByteString key)
public Query prefix(ByteString prefix)
public Query range(String start, String end)
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.public Query range(ByteString start, ByteString end)
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.public Query range(Range.ByteStringRange range)
public Query filter(Filters.Filter filter)
Filters.interleave()
or Filters.chain()
.public Query limit(long limit)
public List<Query> shard(List<KeyOffset> sampledRowKeys)
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<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();
public List<Query> shard(SortedSet<ByteString> splitPoints)
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();
public Range.ByteStringRange getBound()
@InternalApi public ReadRowsRequest toProto(com.google.cloud.bigtable.data.v2.internal.RequestContext requestContext)
public static Query fromProto(@Nonnull ReadRowsRequest request)
ReadRowsRequest
.
WARNING: Please note that the project id & instance id in the table name will be overwritten by the configuration in the BigtableDataClient.
Copyright © 2019 Google LLC. All rights reserved.