BigtableClient

BigtableClient

Service for reading from and writing to existing Bigtable tables.

Constructor

new BigtableClient(optionsopt)

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 <optional>

Use HTTP fallback mode. In fallback mode, a special browser-compatible transport implementation is used instead of gRPC transport. In browser context (if the window object is defined) the fallback mode is enabled automatically; set options.fallback to false if you need to override this behavior.

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

checkAndMutateRow(request, optionsopt) → {Promise}

Mutates a row atomically based on the output of a predicate Reader filter.

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 conditional mutation should be applied. 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.

rowKey Buffer

Required. The key of the row to which the conditional mutation should be applied.

predicateFilter google.bigtable.v2.RowFilter

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 Array.<number>

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 Array.<number>

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.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
Example
const [response] = await client.checkAndMutateRow(request);

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.

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.

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.

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.

mutateRow(request, optionsopt) → {Promise}

Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly changed by mutation.

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 mutation should be applied. 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.

rowKey Buffer

Required. The key of the row to which the mutation should be applied.

mutations Array.<number>

Required. 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.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing MutateRowResponse. Please see the documentation for more details and examples.
Example
const [response] = await client.mutateRow(request);

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.

Example
const stream = client.mutateRows(request);
stream.on('data', (response) => { ... });
stream.on('end', () => { ... });

readModifyWriteRow(request, optionsopt) → {Promise}

Modifies a row atomically on the server. The method reads the latest existing timestamp and value from the specified columns and writes a new entry based on pre-defined read/modify/write rules. The new value for the timestamp is the greater of the existing timestamp or the current server time. The method returns the new contents of all modified cells.

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 read/modify/write rules should be applied. 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.

rowKey Buffer

Required. The key of the row to which the read/modify/write rules should be applied.

rules Array.<number>

Required. 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.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
Example
const [response] = await client.readModifyWriteRow(request);

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. 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 terminate after committing to N rows' worth of results. The default (zero) is to return all results.

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.

Example
const stream = client.readRows(request);
stream.on('data', (response) => { ... });
stream.on('end', () => { ... });

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.

Example
const stream = client.sampleRowKeys(request);
stream.on('data', (response) => { ... });
stream.on('end', () => { ... });

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.