使用ComputeSplitsBySize介面可以將全表資料邏輯上劃分成若干接近指定大小的分區,並返回這些分區之間的分割點以及分區所在機器的提示。一般用於計算引擎規劃並發度等執行計畫。
API說明請參見ComputeSplitPointsBySize。
前提條件
已初始化Client。具體操作,請參見初始化OTSClient。
已建立資料表並寫入資料。具體操作,請參見建立資料表。
介面
/**
* 將全表的資料在邏輯上劃分成接近指定大小的若干分區,返回這些分區之間的分割點以及分區所在機器的提示。
* 一般用於計算引擎規劃並發度等執行計畫。
* @api
* @param [] $request 請求參數。
* @return [] 請求返回。
* @throws OTSClientException 當參數檢查出錯或服務端返回校正出錯時拋出異常。
* @throws OTSServerException 當OTS服務端返回錯誤時拋出異常。
*/
public function computeSplitPointsBySize(array $request)
參數
請求資訊
請求參數
參數 | 說明 |
table_name | 資料表名稱。 |
split_size | 每個分區的近似大小。 單位為百兆(即100 MB)。 |
請求格式
$result = $client->ComputeSplitsBySize([
'table_name' => '<string>', //設定資料表名稱,必須設定。
'split_size' => <integer> //設定分區大小,必須設定。
]); 響應資訊
響應參數
參數 | 說明 |
consumed | 本次操作消耗服務能力單元的值。 capacity_unit表示使用的讀寫單元。
|
primary_key_schema | 資料表的主鍵定義,與建立資料表時的主鍵定義相同。 |
splits | 分區之間的分割點,包括如下內容:
|
結果格式
[
'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>'
],
// ...
]
] 樣本
以下樣本用於將全表資料在邏輯上劃分成接近100 MB的若干分區。
$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']);
}