Split data in a table into several logical splits whose sizes are approximately the same as the specified value

更新时间:
复制 MD 格式

Call the ComputeSplitsBySize operation to split a data table into logical splits of approximately the same size. The response includes the split points between splits and the hosts where each split resides. This operation is typically used to determine execution plans, such as concurrency plans, for compute engines.

Note

For more information, see ComputeSplitPointsBySize.

Prerequisites

API operation

    /**
     * Logically split data in a table into several splits whose sizes are close to the specified size, and return the split points between splits and prompt about hosts in which the splits reside. 
     * In most cases, this operation is used to determine execution plans such as concurrency plans for compute engines. 
     * @api
     * @param [] $request The request parameters. 
     * @return [] The response. 
     * @throws OTSClientException The exception that is thrown when a parameter error occurs or the Tablestore server returns a verification error. 
     * @throws OTSServerException The exception that is thrown when the Tablestore server returns an error. 
     */
    public function computeSplitPointsBySize(array $request)
            

Parameters

Request information

Request parameters

Parameter

Description

table_name

The name of the data table.

split_size

The approximate size of each split. Unit: 100 MB.

Request syntax

$result = $client->ComputeSplitsBySize([
    'table_name' => '<string>', // Required. The name of the data table.
    'split_size' => <integer>   // Required. The approximate size of each split.
]);     

Response information

Response parameters

Parameter

Description

consumed

The capacity units (CUs) consumed by this operation.

capacity_unit contains the read and write CUs consumed:

  • read: the read throughput.

  • write: the write throughput.

primary_key_schema

The primary key schema of the data table, which matches the schema defined at table creation.

splits

The split points between splits. Each split contains the following fields:

  • lower_bound: the minimum primary key value in the split range.

    Pass lower_bound to GetRange to read data within the range.

    • Each entry contains the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType) in sequence.

    • PrimaryKeyType accepts the following values: PrimaryKeyTypeConst::CONST_INTEGER (INTEGER), PrimaryKeyTypeConst::CONST_STRING (UTF-8 encoded string), PrimaryKeyTypeConst::CONST_BINARY (BINARY), PrimaryKeyTypeConst::CONST_INF_MIN (INF_MIN, i.e., -inf), and PrimaryKeyTypeConst::CONST_INF_MAX (INF_MAX, i.e., +inf).

  • upper_bound: the maximum primary key value in the split range. The format is the same as lower_bound.

    Pass upper_bound to GetRange to read data within the range.

  • location: the host where the split resides. This field may be empty.

Response syntax

[
    'consumed' => [
        'capacity_unit' => [
            'read' => <integer>,
            'write' => <integer>
        ]
    ],
    'primary_key_schema' => [
        ['<string>', <PrimaryKeyType>],
        ['<string>', <PrimaryKeyType>, <PrimaryKeyOption>]
    ]
    'splits' => [
        [ 
            'lower_bound' => [
                ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>],
                ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
            ],
            'upper_bound' => [
                ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>],
                ['<string>', <PrimaryKeyValue>, <PrimaryKeyType>]
            ],
            'location' => '<string>'
        ],
        // ...
    ]
]           

Examples

The following example splits a data table into logical splits of approximately 100 MB each (split_size = 1), then prints the location and primary key range of each split.

    $result = $client->ComputeSplitsBySize([
        'table_name' => 'MyTable', 
        'split_size' => 1
    ]);
    foreach($result['splits'] as $split) {
        print_r($split['location']);    
        print_r($split['lower_bound']);    
        print_r($split['upper_bound']);    
    }