Cloud Bigtable V2 Client - Class BigtableClient (1.29.2)

Reference documentation and code samples for the Cloud Bigtable V2 Client class BigtableClient.

Service Description: Service for reading from and writing to existing Bigtable tables.

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:

$bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient();
try {
    $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');
    $rowKey = '...';
    $response = $bigtableClient->checkAndMutateRow($formattedTableName, $rowKey);
} finally {
    $bigtableClient->close();
}

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 parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

This service has a new (beta) implementation. See Google\Cloud\Bigtable\V2\Client\BigtableClient to use the new surface.

Namespace

Google \ Cloud \ Bigtable \ V2

Methods

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

checkAndMutateRow

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

Parameters
NameDescription
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>.

rowKey string

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

optionalArgs array

Optional.

↳ appProfileId string

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

↳ predicateFilter 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 Mutation[]

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 Mutation[]

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.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse;

/**
 * @param string $formattedTableName 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>`. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 * @param string $rowKey             The key of the row to which the conditional mutation should be
 *                                   applied.
 */
function check_and_mutate_row_sample(string $formattedTableName, string $rowKey): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var CheckAndMutateRowResponse $response */
        $response = $bigtableClient->checkAndMutateRow($formattedTableName, $rowKey);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');
    $rowKey = '...';

    check_and_mutate_row_sample($formattedTableName, $rowKey);
}

generateInitialChangeStreamPartitions

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

optionalArgs array

Optional.

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

↳ timeoutMillis int

Timeout to use for this call.

Returns
TypeDescription
Google\ApiCore\ServerStream
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\ServerStream;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsResponse;

/**
 * @param string $formattedTableName 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. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 */
function generate_initial_change_stream_partitions_sample(string $formattedTableName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var ServerStream $stream */
        $stream = $bigtableClient->generateInitialChangeStreamPartitions($formattedTableName);

        /** @var GenerateInitialChangeStreamPartitionsResponse $element */
        foreach ($stream->readAll() as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');

    generate_initial_change_stream_partitions_sample($formattedTableName);
}

mutateRow

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

Parameters
NameDescription
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>.

rowKey string

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

mutations array<Google\Cloud\Bigtable\V2\Mutation>

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.

optionalArgs array

Optional.

↳ appProfileId string

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

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Bigtable\V2\MutateRowResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\MutateRowResponse;
use Google\Cloud\Bigtable\V2\Mutation;

/**
 * @param string $formattedTableName The unique name of the table to which the mutation should be
 *                                   applied. Values are of the form
 *                                   `projects/<project>/instances/<instance>/tables/<table>`. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 * @param string $rowKey             The key of the row to which the mutation should be applied.
 */
function mutate_row_sample(string $formattedTableName, string $rowKey): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $mutations = [new Mutation()];

    // Call the API and handle any network failures.
    try {
        /** @var MutateRowResponse $response */
        $response = $bigtableClient->mutateRow($formattedTableName, $rowKey, $mutations);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');
    $rowKey = '...';

    mutate_row_sample($formattedTableName, $rowKey);
}

mutateRows

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

Parameters
NameDescription
tableName string

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

entries array<Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry>

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.

optionalArgs array

Optional.

↳ appProfileId string

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

↳ timeoutMillis int

Timeout to use for this call.

Returns
TypeDescription
Google\ApiCore\ServerStream
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\ServerStream;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry;
use Google\Cloud\Bigtable\V2\MutateRowsResponse;
use Google\Cloud\Bigtable\V2\Mutation;

/**
 * @param string $formattedTableName The unique name of the table to which the mutations should be
 *                                   applied. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 */
function mutate_rows_sample(string $formattedTableName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $entriesMutations = [new Mutation()];
    $entry = (new Entry())
        ->setMutations($entriesMutations);
    $entries = [$entry,];

    // Call the API and handle any network failures.
    try {
        /** @var ServerStream $stream */
        $stream = $bigtableClient->mutateRows($formattedTableName, $entries);

        /** @var MutateRowsResponse $element */
        foreach ($stream->readAll() as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');

    mutate_rows_sample($formattedTableName);
}

pingAndWarm

Warm up associated instance metadata for this connection.

This call is not required but may be useful for connection keep-alive.

Parameters
NameDescription
name string

Required. The unique name of the instance to check permissions for as well as respond. Values are of the form projects/<project>/instances/<instance>.

optionalArgs array

Optional.

↳ appProfileId string

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

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Bigtable\V2\PingAndWarmResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\PingAndWarmResponse;

/**
 * @param string $formattedName The unique name of the instance to check permissions for as well
 *                              as respond. Values are of the form
 *                              `projects/<project>/instances/<instance>`. Please see
 *                              {@see BigtableClient::instanceName()} for help formatting this field.
 */
function ping_and_warm_sample(string $formattedName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var PingAndWarmResponse $response */
        $response = $bigtableClient->pingAndWarm($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = BigtableClient::instanceName('[PROJECT]', '[INSTANCE]');

    ping_and_warm_sample($formattedName);
}

readChangeStream

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

optionalArgs array

Optional.

↳ 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 StreamPartition

The partition to read changes from.

↳ startTime 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 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 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 Duration

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

↳ timeoutMillis int

Timeout to use for this call.

Returns
TypeDescription
Google\ApiCore\ServerStream
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\ServerStream;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\ReadChangeStreamResponse;

/**
 * @param string $formattedTableName 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. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 */
function read_change_stream_sample(string $formattedTableName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var ServerStream $stream */
        $stream = $bigtableClient->readChangeStream($formattedTableName);

        /** @var ReadChangeStreamResponse $element */
        foreach ($stream->readAll() as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');

    read_change_stream_sample($formattedTableName);
}

readModifyWriteRow

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

rowKey string

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

rules array<Google\Cloud\Bigtable\V2\ReadModifyWriteRule>

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.

optionalArgs array

Optional.

↳ appProfileId string

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

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
TypeDescription
Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse;
use Google\Cloud\Bigtable\V2\ReadModifyWriteRule;

/**
 * @param string $formattedTableName 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>`. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 * @param string $rowKey             The key of the row to which the read/modify/write rules should be
 *                                   applied.
 */
function read_modify_write_row_sample(string $formattedTableName, string $rowKey): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $rules = [new ReadModifyWriteRule()];

    // Call the API and handle any network failures.
    try {
        /** @var ReadModifyWriteRowResponse $response */
        $response = $bigtableClient->readModifyWriteRow($formattedTableName, $rowKey, $rules);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');
    $rowKey = '...';

    read_modify_write_row_sample($formattedTableName, $rowKey);
}

readRows

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
NameDescription
tableName string

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

optionalArgs array

Optional.

↳ appProfileId string

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

↳ rows RowSet

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

↳ filter RowFilter

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

↳ rowsLimit int

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

↳ requestStatsView int

The view into RequestStats, as described above. For allowed values, use constants defined on Google\Cloud\Bigtable\V2\ReadRowsRequest\RequestStatsView

↳ reversed bool

Experimental API - Please note that this API is currently experimental and can change in the future. Return rows in lexiographical descending order of the row keys. The row contents will not be affected by this flag. Example result set: [ {key: "k2", "f:col1": "v1", "f:col2": "v1"}, {key: "k1", "f:col1": "v2", "f:col2": "v2"} ]

↳ timeoutMillis int

Timeout to use for this call.

Returns
TypeDescription
Google\ApiCore\ServerStream
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\ServerStream;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\ReadRowsResponse;

/**
 * @param string $formattedTableName The unique name of the table from which to read.
 *                                   Values are of the form
 *                                   `projects/<project>/instances/<instance>/tables/<table>`. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 */
function read_rows_sample(string $formattedTableName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var ServerStream $stream */
        $stream = $bigtableClient->readRows($formattedTableName);

        /** @var ReadRowsResponse $element */
        foreach ($stream->readAll() as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');

    read_rows_sample($formattedTableName);
}

sampleRowKeys

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

optionalArgs array

Optional.

↳ appProfileId string

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

↳ timeoutMillis int

Timeout to use for this call.

Returns
TypeDescription
Google\ApiCore\ServerStream
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\ServerStream;
use Google\Cloud\Bigtable\V2\BigtableClient;
use Google\Cloud\Bigtable\V2\SampleRowKeysResponse;

/**
 * @param string $formattedTableName The unique name of the table from which to sample row keys.
 *                                   Values are of the form
 *                                   `projects/<project>/instances/<instance>/tables/<table>`. Please see
 *                                   {@see BigtableClient::tableName()} for help formatting this field.
 */
function sample_row_keys_sample(string $formattedTableName): void
{
    // Create a client.
    $bigtableClient = new BigtableClient();

    // Call the API and handle any network failures.
    try {
        /** @var ServerStream $stream */
        $stream = $bigtableClient->sampleRowKeys($formattedTableName);

        /** @var SampleRowKeysResponse $element */
        foreach ($stream->readAll() as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedTableName = BigtableClient::tableName('[PROJECT]', '[INSTANCE]', '[TABLE]');

    sample_row_keys_sample($formattedTableName);
}

static::instanceName

Formats a string containing the fully-qualified path to represent a instance resource.

Parameters
NameDescription
project string
instance string
Returns
TypeDescription
stringThe formatted instance resource.

static::tableName

Formats a string containing the fully-qualified path to represent a table resource.

Parameters
NameDescription
project string
instance string
table string
Returns
TypeDescription
stringThe formatted table resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • instance: projects/{project}/instances/{instance}
  • table: projects/{project}/instances/{instance}/tables/{table}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

Constants

SERVICE_NAME

Value: 'google.bigtable.v2.Bigtable'

The name of the service.

SERVICE_ADDRESS

Value: 'bigtable.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.