Use Tablestore SDK for Java to update the time-to-live (TTL) of time series data and metadata and specify whether metadata attribute columns can be updated.
Prerequisites
Install the Tablestore SDK for Java and initialize a time series client.
Description
Call updateTimeseriesTable to update time series table configurations. Each request can update either time series data configurations or metadata configurations, but not both.
public UpdateTimeseriesTableResponse updateTimeseriesTable(UpdateTimeseriesTableRequest request)
The following example updates the time series data TTL of example_timeseries_table to three years.
TimeseriesClient timeseriesClient = client.asTimeseriesClient();
String tableName = "example_timeseries_table";
UpdateTimeseriesTableRequest request =
new UpdateTimeseriesTableRequest(tableName);
request.setTimeseriesTableOptions(
new TimeseriesTableOptions(86400 * 365 * 3));
timeseriesClient.updateTimeseriesTable(request);
Parameters
UpdateTimeseriesTableRequest contains the following parameters.
|
Name |
Type |
Description |
|
timeseriesTableName (required) |
|
The name of the time series table whose configurations you want to update. |
|
timeseriesTableOptions (optional) |
|
The time series data configurations. You must specify either |
|
timeseriesMetaOptions (optional) |
|
The time series metadata configurations. You must specify either |
Time series data configurations
timeseriesTableOptions is of the TimeseriesTableOptions type and contains the following parameter.
|
Name |
Type |
Description |
|
timeToLive (required) |
|
The time series data TTL in seconds. Set the value to Tablestore automatically deletes expired data. If the metadata TTL is not |
Time series metadata configurations
timeseriesMetaOptions is of the TimeseriesMetaOptions type. Specify at least one of the following parameters. An omitted parameter retains its current value.
|
Name |
Type |
Description |
|
metaTimeToLive (optional) |
|
The time series metadata TTL in seconds. Set the value to This value cannot be less than the time series data TTL. If the data TTL is If you configure a finite TTL, set |
|
allowUpdateAttributes (optional) |
|
Specifies whether metadata attribute columns can be updated. If the metadata TTL is not |
Examples
Update time series metadata configurations
The following example configures time series metadata to never expire and allows metadata attribute columns to be updated.
String tableName = "example_timeseries_table";
TimeseriesMetaOptions metaOptions = new TimeseriesMetaOptions();
metaOptions.setMetaTimeToLive(-1);
metaOptions.setAllowUpdateAttributes(true);
UpdateTimeseriesTableRequest request =
new UpdateTimeseriesTableRequest(tableName);
request.setTimeseriesMetaOptions(metaOptions);
timeseriesClient.updateTimeseriesTable(request);