BigtableClient

BigtableClient

Service for reading from and writing to existing Bigtable tables.

Constructor

new BigtableClient(optionsopt, gaxInstanceopt)

Construct an instance of BigtableClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. The options accepted by the constructor are described in detail in this document. The common options are:

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean | "rest" <optional>

Use HTTP fallback mode. Pass "rest" to use HTTP/1.1 REST API instead of gRPC. For more information, please check the documentation.

gaxInstance gax <optional>

loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new BigtableClient({fallback: 'rest'}, gax);

Members

apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

generateInitialChangeStreamPartitions(request, optionsopt) → {Stream}

NOTE: This API is intended to be used by Apache Beam BigtableIO. Returns the current list of partitions that make up the table's change stream. The union of partitions will cover the entire keyspace. Partitions can be read with ReadChangeStream.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
tableName string

Required. The unique name of the table from which to get change stream partitions. Values are of the form projects/<project>/instances/<instance>/tables/<table>. Change streaming must be enabled on the table.

appProfileId string

This value specifies routing for replication. If not specified, the "default" application profile will be used. Single cluster routing must be configured on the profile.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits GenerateInitialChangeStreamPartitionsResponse on 'data' event. Please see the documentation for more details and examples.

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

instancePath(project, instance) → {string}

Return a fully-qualified instance resource name string.

Parameters:
Name Type Description
project string
instance string
Returns:
Type Description
string

Resource name string.

matchInstanceFromInstanceName(instanceName) → {string}

Parse the instance from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

Returns:
Type Description
string

A string representing the instance.

matchInstanceFromTableName(tableName) → {string}

Parse the instance from Table resource.

Parameters:
Name Type Description
tableName string

A fully-qualified path representing Table resource.

Returns:
Type Description
string

A string representing the instance.

matchProjectFromInstanceName(instanceName) → {string}

Parse the project from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromTableName(tableName) → {string}

Parse the project from Table resource.

Parameters:
Name Type Description
tableName string

A fully-qualified path representing Table resource.

Returns:
Type Description
string

A string representing the project.

matchTableFromTableName(tableName) → {string}

Parse the table from Table resource.

Parameters:
Name Type Description
tableName string

A fully-qualified path representing Table resource.

Returns:
Type Description
string

A string representing the table.

mutateRows(request, optionsopt) → {Stream}

Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, but the entire batch is not executed atomically.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
tableName string

Required. The unique name of the table to which the mutations should be applied.

appProfileId string

This value specifies routing for replication. If not specified, the "default" application profile will be used.

entries Array.<number>

Required. The row keys and corresponding mutations to be applied in bulk. Each entry is applied as an atomic mutation, but the entries may be applied in arbitrary order (even between entries for the same row). At least one entry must be specified, and in total the entries can contain at most 100000 mutations.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits MutateRowsResponse on 'data' event. Please see the documentation for more details and examples.

readChangeStream(request, optionsopt) → {Stream}

NOTE: This API is intended to be used by Apache Beam BigtableIO. Reads changes from a table's change stream. Changes will reflect both user-initiated mutations and mutations that are caused by garbage collection.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
tableName string

Required. The unique name of the table from which to read a change stream. Values are of the form projects/<project>/instances/<instance>/tables/<table>. Change streaming must be enabled on the table.

appProfileId string

This value specifies routing for replication. If not specified, the "default" application profile will be used. Single cluster routing must be configured on the profile.

partition google.bigtable.v2.StreamPartition

The partition to read changes from.

startTime google.protobuf.Timestamp

Start reading the stream at the specified timestamp. This timestamp must be within the change stream retention period, less than or equal to the current time, and after change stream creation, whichever is greater. This value is inclusive and will be truncated to microsecond granularity.

continuationTokens google.bigtable.v2.StreamContinuationTokens

Tokens that describe how to resume reading a stream where reading previously left off. If specified, changes will be read starting at the the position. Tokens are delivered on the stream as part of Heartbeat and CloseStream messages.

If a single token is provided, the token’s partition must exactly match the request’s partition. If multiple tokens are provided, as in the case of a partition merge, the union of the token partitions must exactly cover the request’s partition. Otherwise, INVALID_ARGUMENT will be returned.

endTime google.protobuf.Timestamp

If specified, OK will be returned when the stream advances beyond this time. Otherwise, changes will be continuously delivered on the stream. This value is inclusive and will be truncated to microsecond granularity.

heartbeatDuration google.protobuf.Duration

If specified, the duration between Heartbeat messages on the stream. Otherwise, defaults to 5 seconds.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits ReadChangeStreamResponse on 'data' event. Please see the documentation for more details and examples.

readRows(request, optionsopt) → {Stream}

Streams back the contents of all requested rows in key order, optionally applying the same Reader filter to each. Depending on their size, rows and cells may be broken up across multiple responses, but atomicity of each row will still be preserved. See the ReadRowsResponse documentation for details.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
tableName string

Required. The unique name of the table from which to read. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

appProfileId string

This value specifies routing for replication. If not specified, the "default" application profile will be used.

rows google.bigtable.v2.RowSet

The row keys and/or ranges to read sequentially. If not specified, reads from all rows.

filter google.bigtable.v2.RowFilter

The filter to apply to the contents of the specified row(s). If unset, reads the entirety of each row.

rowsLimit number

The read will stop after committing to N rows' worth of results. The default (zero) is to return all results.

requestStatsView google.bigtable.v2.ReadRowsRequest.RequestStatsView

The view into RequestStats, as described above.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits ReadRowsResponse on 'data' event. Please see the documentation for more details and examples.

sampleRowKeys(request, optionsopt) → {Stream}

Returns a sample of row keys in the table. The returned row keys will delimit contiguous sections of the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
tableName string

Required. The unique name of the table from which to sample row keys. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

appProfileId string

This value specifies routing for replication. If not specified, the "default" application profile will be used.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits SampleRowKeysResponse on 'data' event. Please see the documentation for more details and examples.

tablePath(project, instance, table) → {string}

Return a fully-qualified table resource name string.

Parameters:
Name Type Description
project string
instance string
table string
Returns:
Type Description
string

Resource name string.