/** * 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. * * <p>Expected Usage: * * <pre>{@code * 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(); * }</pre> */ public List<Query> shard(SortedSet<ByteString> splitPoints) { Preconditions.checkState(builder.getRowsLimit() == 0, "Can't shard a query with a row limit"); List<RowSet> shardedRowSets = RowSetUtil.shard(builder.getRows(), splitPoints); List<Query> shards = Lists.newArrayListWithCapacity(shardedRowSets.size()); for (RowSet rowSet : shardedRowSets) { Query queryShard = new Query(tableId); queryShard.builder.mergeFrom(this.builder.build()); queryShard.builder.setRows(rowSet); shards.add(queryShard); } return shards; }
/** * * * <pre> * The row keys and/or ranges to read. If not specified, reads from all rows. * </pre> * * <code>.google.bigtable.v2.RowSet rows = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder> getRowsFieldBuilder() { if (rowsBuilder_ == null) { rowsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder>( getRows(), getParentForChildren(), isClean()); rows_ = null; } return rowsBuilder_; }
/** * 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. * * <p>Expected Usage: * * <pre>{@code * 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(); * }</pre> */ public List<Query> shard(SortedSet<ByteString> splitPoints) { Preconditions.checkState(builder.getRowsLimit() == 0, "Can't shard a query with a row limit"); List<RowSet> shardedRowSets = RowSetUtil.shard(builder.getRows(), splitPoints); List<Query> shards = Lists.newArrayListWithCapacity(shardedRowSets.size()); for (RowSet rowSet : shardedRowSets) { Query queryShard = new Query(tableId); queryShard.builder.mergeFrom(this.builder.build()); queryShard.builder.setRows(rowSet); shards.add(queryShard); } return shards; }
/** * * * <pre> * The row keys and/or ranges to read. If not specified, reads from all rows. * </pre> * * <code>.google.bigtable.v2.RowSet rows = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder> getRowsFieldBuilder() { if (rowsBuilder_ == null) { rowsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder>( getRows(), getParentForChildren(), isClean()); rows_ = null; } return rowsBuilder_; }
/** * <pre> * The row keys and/or ranges to read. If not specified, reads from all rows. * </pre> * * <code>.google.bigtable.v2.RowSet rows = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder> getRowsFieldBuilder() { if (rowsBuilder_ == null) { rowsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.bigtable.v2.RowSet, com.google.bigtable.v2.RowSet.Builder, com.google.bigtable.v2.RowSetOrBuilder>( getRows(), getParentForChildren(), isClean()); rows_ = null; } return rowsBuilder_; }
/** Get the minimal range that encloses all of the row keys and ranges in this Query. */ public ByteStringRange getBound() { return RowSetUtil.getBound(builder.getRows()); }
/** Get the minimal range that encloses all of the row keys and ranges in this Query. */ public ByteStringRange getBound() { return RowSetUtil.getBound(builder.getRows()); }