全部產品
Search
文件中心

Tablestore:建立 Lastpoint 索引

更新時間:Aug 04, 2026

使用 Java SDK 為時序表建立 Lastpoint 索引,以便讀取每條時間軸的最新時間點資料。

前提條件

  • 安裝Tablestore Java SDK並初始化時序模型用戶端。Lastpoint 索引需要使用 5.17.1 及以上版本,建議使用最新版本。

  • 已在支援 Lastpoint 索引的地區建立時序模型執行個體。支援地區及功能詳情參見Lastpoint 索引

功能說明

調用 createTimeseriesLastpointIndex 方法為時序表建立 Lastpoint 索引。索引包含系統產生的分區鍵 _#h、時間軸標識以及每條時間軸的最新時間點資料。

public CreateTimeseriesLastpointIndexResponse createTimeseriesLastpointIndex(CreateTimeseriesLastpointIndexRequest request) throws TableStoreException, ClientException

建立 Lastpoint 索引是非同步作業。將 includeBaseData 設定為 true 時,系統先同步時序表中的存量資料;存量資料同步完成後,索引進入增量同步處理狀態,採用本地索引方式同步新寫入的資料,無同步延遲。設定為 false 時,索引不包含建立前的存量資料,但會同步建立後寫入的資料。

說明

一個時序表的 Lastpoint 索引與分析儲存總數不能超過 10 個。構建 Lastpoint 索引不收費,索引資料存放區和讀取會產生費用;使用 SQL 或多元索引查詢時,還會產生相應功能的費用。計費詳情參見時序模型計量計費SQL 查詢計量計費多元索引計量計費

以下樣本為 example_timeseries_table 建立 example_lastpoint_index,並同步存量資料。

TimeseriesClient timeseriesClient = client.asTimeseriesClient();

CreateTimeseriesLastpointIndexRequest request =
        new CreateTimeseriesLastpointIndexRequest(
                "example_timeseries_table",
                "example_lastpoint_index",
                true);

timeseriesClient.createTimeseriesLastpointIndex(request);

也可以在建立時序表時同時建立 Lastpoint 索引。

參數說明

CreateTimeseriesLastpointIndexRequest 包含以下參數。

名稱

類型

說明

timeseriesTableName(必選)

String

時序表名稱。

lastpointIndexName(必選)

String

Lastpoint 索引名稱。

includeBaseData(必選)

boolean

是否同步索引建立前的存量資料。設定為 true 時同步存量資料;設定為 false 時不包含存量資料。兩種取值都會同步索引建立後寫入的資料。