com.google.cloud.bigtable.grpc
Class BigtableDataGrpcClient
- java.lang.Object
-
- com.google.cloud.bigtable.grpc.BigtableDataGrpcClient
-
- All Implemented Interfaces:
- BigtableDataClient
public class BigtableDataGrpcClient extends Object implements BigtableDataClient
A gRPC client to access the v2 Bigtable data service.In addition to calling the underlying data service API via grpc, this class adds retry logic and some useful headers.
Most of the methods are unary (single response). The only exception is ReadRows which is a streaming call.
- Version:
- $Id: $Id
- Author:
- sduskis
-
-
Field Summary
Fields Modifier and Type Field and Description static Predicate<com.google.bigtable.v2.MutateRowRequest>
IS_RETRYABLE_MUTATION
ConstantIS_RETRYABLE_MUTATION
-
Constructor Summary
Constructors Constructor and Description BigtableDataGrpcClient(io.grpc.Channel channel, ScheduledExecutorService retryExecutorService, BigtableOptions bigtableOptions)
Constructor for BigtableDataGrpcClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description com.google.bigtable.v2.CheckAndMutateRowResponse
checkAndMutateRow(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Mutate a row atomically dependent on a precondition.ListenableFuture<com.google.bigtable.v2.CheckAndMutateRowResponse>
checkAndMutateRowAsync(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Mutate a row atomically dependent on a precondition.com.google.bigtable.v2.MutateRowResponse
mutateRow(com.google.bigtable.v2.MutateRowRequest request)
Mutate a row atomically.ListenableFuture<com.google.bigtable.v2.MutateRowResponse>
mutateRowAsync(com.google.bigtable.v2.MutateRowRequest request)
Mutate a row atomically.List<com.google.bigtable.v2.MutateRowsResponse>
mutateRows(com.google.bigtable.v2.MutateRowsRequest request)
Mutates multiple rows in a batch.ListenableFuture<List<com.google.bigtable.v2.MutateRowsResponse>>
mutateRowsAsync(com.google.bigtable.v2.MutateRowsRequest request)
Mutates multiple rows in a batch.ResultScanner<FlatRow>
readFlatRows(com.google.bigtable.v2.ReadRowsRequest request)
Perform a scan overFlatRow
s, in key order.ScanHandler
readFlatRows(com.google.bigtable.v2.ReadRowsRequest request, io.grpc.stub.StreamObserver<FlatRow> observer)
Perform a streaming read ofFlatRow
s in key order.ListenableFuture<List<FlatRow>>
readFlatRowsAsync(com.google.bigtable.v2.ReadRowsRequest request)
Read multipleFlatRow
s into an in-memory list, in key order.List<FlatRow>
readFlatRowsList(com.google.bigtable.v2.ReadRowsRequest request)
Returns a list ofFlatRow
s, in key order.com.google.bigtable.v2.ReadModifyWriteRowResponse
readModifyWriteRow(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Perform an atomic read-modify-write operation on a row.ListenableFuture<com.google.bigtable.v2.ReadModifyWriteRowResponse>
readModifyWriteRowAsync(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Perform an atomic read-modify-write operation on a row,ResultScanner<com.google.bigtable.v2.Row>
readRows(com.google.bigtable.v2.ReadRowsRequest request)
Perform a scan overRow
s, in key order.ListenableFuture<List<com.google.bigtable.v2.Row>>
readRowsAsync(com.google.bigtable.v2.ReadRowsRequest request)
Read multipleRow
s into an in-memory list, in key order.List<com.google.bigtable.v2.SampleRowKeysResponse>
sampleRowKeys(com.google.bigtable.v2.SampleRowKeysRequest request)
Sample row keys from a table.ListenableFuture<List<com.google.bigtable.v2.SampleRowKeysResponse>>
sampleRowKeysAsync(com.google.bigtable.v2.SampleRowKeysRequest request)
Sample row keys from a table, returning a Future that will complete when the sampling has completed.void
setCallOptionsFactory(CallOptionsFactory callOptionsFactory)
Sets aCallOptionsFactory
which createsCallOptions
-
-
-
Field Detail
-
IS_RETRYABLE_MUTATION
public static final Predicate<com.google.bigtable.v2.MutateRowRequest> IS_RETRYABLE_MUTATION
ConstantIS_RETRYABLE_MUTATION
-
-
Constructor Detail
-
BigtableDataGrpcClient
public BigtableDataGrpcClient(io.grpc.Channel channel, ScheduledExecutorService retryExecutorService, BigtableOptions bigtableOptions)
Constructor for BigtableDataGrpcClient.- Parameters:
channel
- aChannel
object.retryExecutorService
- aScheduledExecutorService
object.bigtableOptions
- aBigtableOptions
object.
-
-
Method Detail
-
setCallOptionsFactory
public void setCallOptionsFactory(CallOptionsFactory callOptionsFactory)
Sets aCallOptionsFactory
which createsCallOptions
- Specified by:
setCallOptionsFactory
in interfaceBigtableDataClient
- Parameters:
callOptionsFactory
- aCallOptionsFactory
object.
-
mutateRow
public com.google.bigtable.v2.MutateRowResponse mutateRow(com.google.bigtable.v2.MutateRowRequest request)
Mutate a row atomically.- Specified by:
mutateRow
in interfaceBigtableDataClient
- Parameters:
request
- aMutateRowRequest
object.- Returns:
- a
MutateRowResponse
object.
-
mutateRowAsync
public ListenableFuture<com.google.bigtable.v2.MutateRowResponse> mutateRowAsync(com.google.bigtable.v2.MutateRowRequest request)
Mutate a row atomically.- Specified by:
mutateRowAsync
in interfaceBigtableDataClient
- Parameters:
request
- aMutateRowRequest
object.- Returns:
- a
ListenableFuture
that will finish when the mutation has completed.
-
mutateRows
public List<com.google.bigtable.v2.MutateRowsResponse> mutateRows(com.google.bigtable.v2.MutateRowsRequest request)
Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, but the entire batch is not executed atomically.- Specified by:
mutateRows
in interfaceBigtableDataClient
- Parameters:
request
- aMutateRowsRequest
object.- Returns:
- a
List
object.
-
mutateRowsAsync
public ListenableFuture<List<com.google.bigtable.v2.MutateRowsResponse>> mutateRowsAsync(com.google.bigtable.v2.MutateRowsRequest request)
Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, but the entire batch is not executed atomically.- Specified by:
mutateRowsAsync
in interfaceBigtableDataClient
- Parameters:
request
- aMutateRowsRequest
object.- Returns:
- a
ListenableFuture
that will finish when the mutations have all been completed.
-
checkAndMutateRow
public com.google.bigtable.v2.CheckAndMutateRowResponse checkAndMutateRow(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Mutate a row atomically dependent on a precondition.- Specified by:
checkAndMutateRow
in interfaceBigtableDataClient
- Parameters:
request
- aCheckAndMutateRowRequest
object.- Returns:
- a
CheckAndMutateRowResponse
object.
-
checkAndMutateRowAsync
public ListenableFuture<com.google.bigtable.v2.CheckAndMutateRowResponse> checkAndMutateRowAsync(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Mutate a row atomically dependent on a precondition.- Specified by:
checkAndMutateRowAsync
in interfaceBigtableDataClient
- Parameters:
request
- aCheckAndMutateRowRequest
object.- Returns:
- a
ListenableFuture
that will finish when the mutation has completed.
-
readModifyWriteRow
public com.google.bigtable.v2.ReadModifyWriteRowResponse readModifyWriteRow(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Perform an atomic read-modify-write operation on a row.- Specified by:
readModifyWriteRow
in interfaceBigtableDataClient
- Parameters:
request
- aReadModifyWriteRowRequest
object.- Returns:
- a
ReadModifyWriteRowResponse
object.
-
readModifyWriteRowAsync
public ListenableFuture<com.google.bigtable.v2.ReadModifyWriteRowResponse> readModifyWriteRowAsync(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Perform an atomic read-modify-write operation on a row,- Specified by:
readModifyWriteRowAsync
in interfaceBigtableDataClient
- Parameters:
request
- aReadModifyWriteRowRequest
object.- Returns:
- a
ListenableFuture
that will finish when the mutation has completed.
-
sampleRowKeys
public List<com.google.bigtable.v2.SampleRowKeysResponse> sampleRowKeys(com.google.bigtable.v2.SampleRowKeysRequest request)
Sample row keys from a table.- Specified by:
sampleRowKeys
in interfaceBigtableDataClient
- Parameters:
request
- aSampleRowKeysRequest
object.- Returns:
- an immutable
List
object.
-
sampleRowKeysAsync
public ListenableFuture<List<com.google.bigtable.v2.SampleRowKeysResponse>> sampleRowKeysAsync(com.google.bigtable.v2.SampleRowKeysRequest request)
Sample row keys from a table, returning a Future that will complete when the sampling has completed.- Specified by:
sampleRowKeysAsync
in interfaceBigtableDataClient
- Parameters:
request
- aSampleRowKeysRequest
object.- Returns:
- a
ListenableFuture
object.
-
readRowsAsync
public ListenableFuture<List<com.google.bigtable.v2.Row>> readRowsAsync(com.google.bigtable.v2.ReadRowsRequest request)
Read multipleRow
s into an in-memory list, in key order.- Specified by:
readRowsAsync
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.- Returns:
- a
ListenableFuture
that will finish when all reads have completed.
-
readFlatRowsAsync
public ListenableFuture<List<FlatRow>> readFlatRowsAsync(com.google.bigtable.v2.ReadRowsRequest request)
Read multipleFlatRow
s into an in-memory list, in key order.- Specified by:
readFlatRowsAsync
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.- Returns:
- a
ListenableFuture
that will finish when all reads have completed.
-
readFlatRowsList
public List<FlatRow> readFlatRowsList(com.google.bigtable.v2.ReadRowsRequest request)
Returns a list ofFlatRow
s, in key order.- Specified by:
readFlatRowsList
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.- Returns:
- a List with
FlatRow
s.
-
readRows
public ResultScanner<com.google.bigtable.v2.Row> readRows(com.google.bigtable.v2.ReadRowsRequest request)
Perform a scan overRow
s, in key order.- Specified by:
readRows
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.- Returns:
- a
ResultScanner
object.
-
readFlatRows
public ResultScanner<FlatRow> readFlatRows(com.google.bigtable.v2.ReadRowsRequest request)
Perform a scan overFlatRow
s, in key order.- Specified by:
readFlatRows
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.- Returns:
- a
ResultScanner
object.
-
readFlatRows
public ScanHandler readFlatRows(com.google.bigtable.v2.ReadRowsRequest request, io.grpc.stub.StreamObserver<FlatRow> observer)
Perform a streaming read ofFlatRow
s in key order. It would be a good idea to turn on client side timeouts viaCallOptionsConfig.Builder.setUseTimeout(boolean)
.- Specified by:
readFlatRows
in interfaceBigtableDataClient
- Parameters:
request
- aReadRowsRequest
object.observer
- aStreamObserver
object- Returns:
- a
ScanHandler
which can be used to either cancel or timeout the request.
-
-