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. See the subsequent parameters for more details.

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.

promise function <optional>

Custom promise module to use instead of native Promises.

apiEndpoint string <optional>

The domain name of the API remote host.

Source:

Members

(static) apiEndpoint

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

Source:

(static) port

The port for this API service.

Source:

(static) scopes

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

Source:

(static) servicePath

The DNS address for this API service.

Source:

Methods

checkAndMutateRow(request, optionsopt, callbackopt) → {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 Attributes Description
tableName string

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 Buffer

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

appProfileId string <optional>

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

predicateFilter Object <optional>

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.

This object should have the same structure as RowFilter

trueMutations Array.<Object> <optional>

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.

This object should have the same structure as Mutation

falseMutations Array.<Object> <optional>

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.

This object should have the same structure as Mutation

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing CheckAndMutateRowResponse.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
const rowKey = Buffer.from('');
const request = {
  tableName: formattedTableName,
  rowKey: rowKey,
};
client.checkAndMutateRow(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

Source:

matchInstanceFromTableName(tableName) → {String}

Parse the tableName from a table resource.

Parameters:
Name Type Description
tableName String

A fully-qualified path representing a table resources.

Source:

matchProjectFromTableName(tableName) → {String}

Parse the tableName from a table resource.

Parameters:
Name Type Description
tableName String

A fully-qualified path representing a table resources.

Source:

matchTableFromTableName(tableName) → {String}

Parse the tableName from a table resource.

Parameters:
Name Type Description
tableName String

A fully-qualified path representing a table resources.

Source:

mutateRow(request, optionsopt, callbackopt) → {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 Attributes Description
tableName string

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 Buffer

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

mutations Array.<Object>

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.

This object should have the same structure as Mutation

appProfileId string <optional>

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

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing MutateRowResponse.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
const rowKey = Buffer.from('');
const mutations = [];
const request = {
  tableName: formattedTableName,
  rowKey: rowKey,
  mutations: mutations,
};
client.mutateRow(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

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 Attributes Description
tableName string

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

entries Array.<Object>

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.

This object should have the same structure as Entry

appProfileId string <optional>

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

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
const entries = [];
const request = {
  tableName: formattedTableName,
  entries: entries,
};
client.mutateRows(request).on('data', response => {
  // doThingsWith(response)
});

readModifyWriteRow(request, optionsopt, callbackopt) → {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 Attributes Description
tableName string

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 Buffer

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

rules Array.<Object>

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.

This object should have the same structure as ReadModifyWriteRule

appProfileId string <optional>

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

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ReadModifyWriteRowResponse.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
const rowKey = Buffer.from('');
const rules = [];
const request = {
  tableName: formattedTableName,
  rowKey: rowKey,
  rules: rules,
};
client.readModifyWriteRow(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

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 Attributes Description
tableName string

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

appProfileId string <optional>

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

rows Object <optional>

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

This object should have the same structure as RowSet

filter Object <optional>

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

This object should have the same structure as RowFilter

rowsLimit number <optional>

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

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
client.readRows({tableName: formattedTableName}).on('data', response => {
  // doThingsWith(response)
});

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 Attributes Description
tableName string

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

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

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
Example
const bigtable = require('@google-cloud/bigtable');

const client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

const formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
client.sampleRowKeys({tableName: formattedTableName}).on('data', response => {
  // doThingsWith(response)
});

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

Return a fully-qualified table resource name string.

Parameters:
Name Type Description
project String
instance String
table String
Source: