@Generated(value="by gapic-generator") @BetaApi public class BaseBigtableDataClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<Mutation> mutations = new ArrayList<>();
MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName, rowKey, mutations);
}
Note: close() needs to be called on the baseBigtableDataClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of BaseBigtableDataSettings to create(). For example:
To customize credentials:
BaseBigtableDataSettings baseBigtableDataSettings =
BaseBigtableDataSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
BaseBigtableDataClient baseBigtableDataClient =
BaseBigtableDataClient.create(baseBigtableDataSettings);
To customize the endpoint:
BaseBigtableDataSettings baseBigtableDataSettings =
BaseBigtableDataSettings.newBuilder().setEndpoint(myEndpoint).build();
BaseBigtableDataClient baseBigtableDataClient =
BaseBigtableDataClient.create(baseBigtableDataSettings);
Modifier | Constructor and Description |
---|---|
protected |
BaseBigtableDataClient(BaseBigtableDataSettings settings)
Constructs an instance of BaseBigtableDataClient, using the given settings.
|
protected |
BaseBigtableDataClient(BigtableStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.bigtable.v2.CheckAndMutateRowResponse |
checkAndMutateRow(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Mutates a row atomically based on the output of a predicate Reader filter.
|
com.google.bigtable.v2.CheckAndMutateRowResponse |
checkAndMutateRow(String tableName,
ByteString rowKey,
com.google.bigtable.v2.RowFilter predicateFilter,
List<com.google.bigtable.v2.Mutation> trueMutations,
List<com.google.bigtable.v2.Mutation> falseMutations)
Mutates a row atomically based on the output of a predicate Reader filter.
|
com.google.bigtable.v2.CheckAndMutateRowResponse |
checkAndMutateRow(com.google.bigtable.v2.TableName tableName,
ByteString rowKey,
com.google.bigtable.v2.RowFilter predicateFilter,
List<com.google.bigtable.v2.Mutation> trueMutations,
List<com.google.bigtable.v2.Mutation> falseMutations)
Mutates a row atomically based on the output of a predicate Reader filter.
|
UnaryCallable<com.google.bigtable.v2.CheckAndMutateRowRequest,com.google.bigtable.v2.CheckAndMutateRowResponse> |
checkAndMutateRowCallable()
Mutates a row atomically based on the output of a predicate Reader filter.
|
void |
close() |
static BaseBigtableDataClient |
create()
Constructs an instance of BaseBigtableDataClient with default settings.
|
static BaseBigtableDataClient |
create(BaseBigtableDataSettings settings)
Constructs an instance of BaseBigtableDataClient, using the given settings.
|
static BaseBigtableDataClient |
create(BigtableStub stub)
Constructs an instance of BaseBigtableDataClient, using the given stub for making calls.
|
BaseBigtableDataSettings |
getSettings() |
BigtableStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.bigtable.v2.MutateRowResponse |
mutateRow(com.google.bigtable.v2.MutateRowRequest request)
Mutates a row atomically.
|
com.google.bigtable.v2.MutateRowResponse |
mutateRow(String tableName,
ByteString rowKey,
List<com.google.bigtable.v2.Mutation> mutations)
Mutates a row atomically.
|
com.google.bigtable.v2.MutateRowResponse |
mutateRow(com.google.bigtable.v2.TableName tableName,
ByteString rowKey,
List<com.google.bigtable.v2.Mutation> mutations)
Mutates a row atomically.
|
UnaryCallable<com.google.bigtable.v2.MutateRowRequest,com.google.bigtable.v2.MutateRowResponse> |
mutateRowCallable()
Mutates a row atomically.
|
ServerStreamingCallable<com.google.bigtable.v2.MutateRowsRequest,com.google.bigtable.v2.MutateRowsResponse> |
mutateRowsCallable()
Mutates multiple rows in a batch.
|
com.google.bigtable.v2.ReadModifyWriteRowResponse |
readModifyWriteRow(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Modifies a row atomically on the server.
|
com.google.bigtable.v2.ReadModifyWriteRowResponse |
readModifyWriteRow(String tableName,
ByteString rowKey,
List<com.google.bigtable.v2.ReadModifyWriteRule> rules)
Modifies a row atomically on the server.
|
com.google.bigtable.v2.ReadModifyWriteRowResponse |
readModifyWriteRow(com.google.bigtable.v2.TableName tableName,
ByteString rowKey,
List<com.google.bigtable.v2.ReadModifyWriteRule> rules)
Modifies a row atomically on the server.
|
UnaryCallable<com.google.bigtable.v2.ReadModifyWriteRowRequest,com.google.bigtable.v2.ReadModifyWriteRowResponse> |
readModifyWriteRowCallable()
Modifies a row atomically on the server.
|
ServerStreamingCallable<com.google.bigtable.v2.ReadRowsRequest,com.google.bigtable.v2.ReadRowsResponse> |
readRowsCallable()
Streams back the contents of all requested rows in key order, optionally applying the same
Reader filter to each.
|
ServerStreamingCallable<com.google.bigtable.v2.SampleRowKeysRequest,com.google.bigtable.v2.SampleRowKeysResponse> |
sampleRowKeysCallable()
Returns a sample of row keys in the table.
|
void |
shutdown() |
void |
shutdownNow() |
protected BaseBigtableDataClient(BaseBigtableDataSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected BaseBigtableDataClient(BigtableStub stub)
public static final BaseBigtableDataClient create() throws IOException
IOException
public static final BaseBigtableDataClient create(BaseBigtableDataSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final BaseBigtableDataClient create(BigtableStub stub)
public final BaseBigtableDataSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public BigtableStub getStub()
public final ServerStreamingCallable<com.google.bigtable.v2.ReadRowsRequest,com.google.bigtable.v2.ReadRowsResponse> readRowsCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ReadRowsRequest request = ReadRowsRequest.newBuilder()
.setTableName(tableName.toString())
.build();
ServerStream<ReadRowsResponse> stream = baseBigtableDataClient.readRowsCallable().call(request);
for (ReadRowsResponse response : stream) {
// Do something when receive a response
}
}
public final ServerStreamingCallable<com.google.bigtable.v2.SampleRowKeysRequest,com.google.bigtable.v2.SampleRowKeysResponse> sampleRowKeysCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
SampleRowKeysRequest request = SampleRowKeysRequest.newBuilder()
.setTableName(tableName.toString())
.build();
ServerStream<SampleRowKeysResponse> stream = baseBigtableDataClient.sampleRowKeysCallable().call(request);
for (SampleRowKeysResponse response : stream) {
// Do something when receive a response
}
}
public final com.google.bigtable.v2.MutateRowResponse mutateRow(com.google.bigtable.v2.TableName tableName, ByteString rowKey, List<com.google.bigtable.v2.Mutation> mutations)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<Mutation> mutations = new ArrayList<>();
MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName, rowKey, mutations);
}
tableName
- The unique name of the table to which the mutation should be applied. Values
are of the form `projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the mutation should be applied.mutations
- Changes to be atomically applied to the specified row. Entries are applied in
order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry and at most 100000.ApiException
- if the remote call failspublic final com.google.bigtable.v2.MutateRowResponse mutateRow(String tableName, ByteString rowKey, List<com.google.bigtable.v2.Mutation> mutations)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<Mutation> mutations = new ArrayList<>();
MutateRowResponse response = baseBigtableDataClient.mutateRow(tableName.toString(), rowKey, mutations);
}
tableName
- The unique name of the table to which the mutation should be applied. Values
are of the form `projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the mutation should be applied.mutations
- Changes to be atomically applied to the specified row. Entries are applied in
order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry and at most 100000.ApiException
- if the remote call failspublic final com.google.bigtable.v2.MutateRowResponse mutateRow(com.google.bigtable.v2.MutateRowRequest request)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<Mutation> mutations = new ArrayList<>();
MutateRowRequest request = MutateRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.addAllMutations(mutations)
.build();
MutateRowResponse response = baseBigtableDataClient.mutateRow(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.bigtable.v2.MutateRowRequest,com.google.bigtable.v2.MutateRowResponse> mutateRowCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<Mutation> mutations = new ArrayList<>();
MutateRowRequest request = MutateRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.addAllMutations(mutations)
.build();
ApiFuture<MutateRowResponse> future = baseBigtableDataClient.mutateRowCallable().futureCall(request);
// Do something
MutateRowResponse response = future.get();
}
public final ServerStreamingCallable<com.google.bigtable.v2.MutateRowsRequest,com.google.bigtable.v2.MutateRowsResponse> mutateRowsCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
List<MutateRowsRequest.Entry> entries = new ArrayList<>();
MutateRowsRequest request = MutateRowsRequest.newBuilder()
.setTableName(tableName.toString())
.addAllEntries(entries)
.build();
ServerStream<MutateRowsResponse> stream = baseBigtableDataClient.mutateRowsCallable().call(request);
for (MutateRowsResponse response : stream) {
// Do something when receive a response
}
}
public final com.google.bigtable.v2.CheckAndMutateRowResponse checkAndMutateRow(com.google.bigtable.v2.TableName tableName, ByteString rowKey, com.google.bigtable.v2.RowFilter predicateFilter, List<com.google.bigtable.v2.Mutation> trueMutations, List<com.google.bigtable.v2.Mutation> falseMutations)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
RowFilter predicateFilter = RowFilter.newBuilder().build();
List<Mutation> trueMutations = new ArrayList<>();
List<Mutation> falseMutations = new ArrayList<>();
CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations);
}
tableName
- The unique name of the table to which the conditional mutation should be
applied. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the conditional mutation should be applied.predicateFilter
- The filter to be applied to the contents of the specified row. Depending
on whether or not any results are yielded, either `true_mutations` or `false_mutations`
will be executed. If unset, checks that the row contains any values at all.trueMutations
- Changes to be atomically applied to the specified row if
`predicate_filter` yields at least one cell when applied to `row_key`. Entries are applied
in order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry if `false_mutations` is empty, and at most 100000.falseMutations
- Changes to be atomically applied to the specified row if
`predicate_filter` does not yield any cells when applied to `row_key`. Entries are applied
in order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry if `true_mutations` is empty, and at most 100000.ApiException
- if the remote call failspublic final com.google.bigtable.v2.CheckAndMutateRowResponse checkAndMutateRow(String tableName, ByteString rowKey, com.google.bigtable.v2.RowFilter predicateFilter, List<com.google.bigtable.v2.Mutation> trueMutations, List<com.google.bigtable.v2.Mutation> falseMutations)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
RowFilter predicateFilter = RowFilter.newBuilder().build();
List<Mutation> trueMutations = new ArrayList<>();
List<Mutation> falseMutations = new ArrayList<>();
CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(tableName.toString(), rowKey, predicateFilter, trueMutations, falseMutations);
}
tableName
- The unique name of the table to which the conditional mutation should be
applied. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the conditional mutation should be applied.predicateFilter
- The filter to be applied to the contents of the specified row. Depending
on whether or not any results are yielded, either `true_mutations` or `false_mutations`
will be executed. If unset, checks that the row contains any values at all.trueMutations
- Changes to be atomically applied to the specified row if
`predicate_filter` yields at least one cell when applied to `row_key`. Entries are applied
in order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry if `false_mutations` is empty, and at most 100000.falseMutations
- Changes to be atomically applied to the specified row if
`predicate_filter` does not yield any cells when applied to `row_key`. Entries are applied
in order, meaning that earlier mutations can be masked by later ones. Must contain at least
one entry if `true_mutations` is empty, and at most 100000.ApiException
- if the remote call failspublic final com.google.bigtable.v2.CheckAndMutateRowResponse checkAndMutateRow(com.google.bigtable.v2.CheckAndMutateRowRequest request)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.build();
CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.bigtable.v2.CheckAndMutateRowRequest,com.google.bigtable.v2.CheckAndMutateRowResponse> checkAndMutateRowCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.build();
ApiFuture<CheckAndMutateRowResponse> future = baseBigtableDataClient.checkAndMutateRowCallable().futureCall(request);
// Do something
CheckAndMutateRowResponse response = future.get();
}
public final com.google.bigtable.v2.ReadModifyWriteRowResponse readModifyWriteRow(com.google.bigtable.v2.TableName tableName, ByteString rowKey, List<com.google.bigtable.v2.ReadModifyWriteRule> rules)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<ReadModifyWriteRule> rules = new ArrayList<>();
ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(tableName, rowKey, rules);
}
tableName
- The unique name of the table to which the read/modify/write rules should be
applied. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the read/modify/write rules should be applied.rules
- Rules specifying how the specified row's contents are to be transformed into
writes. Entries are applied in order, meaning that earlier rules will affect the results of
later ones.ApiException
- if the remote call failspublic final com.google.bigtable.v2.ReadModifyWriteRowResponse readModifyWriteRow(String tableName, ByteString rowKey, List<com.google.bigtable.v2.ReadModifyWriteRule> rules)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<ReadModifyWriteRule> rules = new ArrayList<>();
ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(tableName.toString(), rowKey, rules);
}
tableName
- The unique name of the table to which the read/modify/write rules should be
applied. Values are of the form
`projects/<project>/instances/<instance>/tables/<table>`.rowKey
- The key of the row to which the read/modify/write rules should be applied.rules
- Rules specifying how the specified row's contents are to be transformed into
writes. Entries are applied in order, meaning that earlier rules will affect the results of
later ones.ApiException
- if the remote call failspublic final com.google.bigtable.v2.ReadModifyWriteRowResponse readModifyWriteRow(com.google.bigtable.v2.ReadModifyWriteRowRequest request)
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<ReadModifyWriteRule> rules = new ArrayList<>();
ReadModifyWriteRowRequest request = ReadModifyWriteRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.addAllRules(rules)
.build();
ReadModifyWriteRowResponse response = baseBigtableDataClient.readModifyWriteRow(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.bigtable.v2.ReadModifyWriteRowRequest,com.google.bigtable.v2.ReadModifyWriteRowResponse> readModifyWriteRowCallable()
Sample code:
try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ByteString rowKey = ByteString.copyFromUtf8("");
List<ReadModifyWriteRule> rules = new ArrayList<>();
ReadModifyWriteRowRequest request = ReadModifyWriteRowRequest.newBuilder()
.setTableName(tableName.toString())
.setRowKey(rowKey)
.addAllRules(rules)
.build();
ApiFuture<ReadModifyWriteRowResponse> future = baseBigtableDataClient.readModifyWriteRowCallable().futureCall(request);
// Do something
ReadModifyWriteRowResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.