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.
For more information, see ComputeSplitPointsBySize.
Prerequisites
The client has been initialized. For more information, see Initialize the Tablestore client.
A data table has been created and data has been written to it. For more information, see Create a data table.
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:
|
|
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:
|
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']);
}