Use Tablestore SDK for Java to create a Lastpoint index for a time series table and read the latest data point of each time series.
Prerequisites
Before you begin, ensure that you have:
Tablestore SDK for Java 5.17.1 or later installed and a time series client initialized. We recommend that you use the latest version.
A time series model instance in a region that supports Lastpoint indexes. For supported regions and feature details, see Lastpoint indexes.
Description
Call createTimeseriesLastpointIndex to create a Lastpoint index for a time series table. The index contains the system-generated _#h partition key, time series identifiers, and the latest data point of each time series.
public CreateTimeseriesLastpointIndexResponse createTimeseriesLastpointIndex(CreateTimeseriesLastpointIndexRequest request) throws TableStoreException, ClientException
Creating a Lastpoint index is asynchronous. If includeBaseData is true, Tablestore first synchronizes existing data from the time series table. After the initial synchronization is complete, the index enters incremental synchronization. New data is synchronized by using local indexing with no synchronization latency. If includeBaseData is false, the index excludes data written before the index was created but synchronizes new data.
A time series table can have up to 10 Lastpoint indexes and analytical stores in total. Creating a Lastpoint index is free of charge. Storage and reads are billed. SQL queries and search index queries incur additional fees. For billing details, see Billing of the time series model, Billing of SQL queries, and Billing of search indexes.
The following example creates example_lastpoint_index for example_timeseries_table and includes existing data.
TimeseriesClient timeseriesClient = client.asTimeseriesClient();
CreateTimeseriesLastpointIndexRequest request =
new CreateTimeseriesLastpointIndexRequest(
"example_timeseries_table",
"example_lastpoint_index",
true);
timeseriesClient.createTimeseriesLastpointIndex(request);
You can also create a Lastpoint index when you create a time series table.
Parameters
CreateTimeseriesLastpointIndexRequest contains the following parameters.
|
Name |
Type |
Description |
|
timeseriesTableName (required) |
|
The time series table name. |
|
lastpointIndexName (required) |
|
The Lastpoint index name. |
|
includeBaseData (required) |
|
Specifies whether to synchronize data written before the index is created. A value of |