ComputeSplitsBySize

API description: ComputeSplitPointsBySize

You can call the ComputeSplitsBySize operation to logically split data in a table into several partitions whose sizes are close to the specified size. This operation returns the split points between partitions and prompt about hosts where the partitions reside. This operation is generally used for execution plans on computing engines, such as concurrency plans.

Method
    /**
     * Logically split data in a table into several partitions whose sizes are close to the specified size, and return the split points between partitions and prompt about hosts where the partitions reside.
     * This operation is generally used for execution plans on computing engines, such as concurrency plans.
     * @api
     * @param [] $request The request parameters.
     * @return [] The response.
     * @throws OTSClientException The exception that is thrown when a parameter check error occurs or the Table Store server returns a verification error.
     * @throws OTSServerException The exception that is thrown when the Table Store server returns an error.
     */
    public function computeSplitPointsBySize(array $request)
			
Request format
$result = $client->ComputeSplitsBySize([
    'table_name' => '<string>', // Required.
    'split_size' => <integer>   // Required.
]);     
Request format description
  • table_name: the table name.
  • split_size: the approximate size of each partition. Unit: megabytes.
Response format
[
    '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>'
        ],
        // ...
    ]
]           
Response format description
  • consumed: the number of CUs consumed by this operation.
    • capacity_unit: the number of read and write CUs consumed.
      • read: the number of read CUs consumed.
      • write: the number of write CUs consumed.
  • primary_key_schema: the schema of the primary key of the table, which is the same as that specified when the table was created.
  • splits: the split points between partitions.
    • lower_bound: the minimum value in the range of the primary key. Note: This parameter value can be used by GetRange.
      • Each item contains the primary key name, primary key value (PrimaryKeyValue), and primary key type (PrimaryKeyType).
      • PrimaryKeyType can be set to PrimaryKeyTypeConst::CONST_INTEGER, PrimaryKeyTypeConst::CONST_STRING, PrimaryKeyTypeConst::CONST_BINARY, PrimaryKeyTypeConst::CONST_INF_MIN, or PrimaryKeyTypeConst::CONST_INF_MAX, which respectively indicate the INTEGER, STRING (UTF-8 encoded string), BINARY, INF_MIN(-inf), and INF_MAX(inf) types.
    • upper_bound: the maximum value in the range of the primary key. The format is the same as that of lower_bound.
    • location: the prompt about the hosts where the partitions reside. This parameter can be null.
Example

The following code provides an example of how to split data with a specified size:

    $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']);    
    }