You can call the CreateTimeseriesTable operation to create a time series table. When you create a time series table, you can configure the time to live (TTL) of data and parameters about time series metadata.
Prerequisites
An instance for the TimeSeries model is created in the Tablestore console. For more information, see Create an instance for the TimeSeries model.
A TimeseriesClient instance is initialized. For more information, see Initialize an OTSClient instance.
Usage notes
The name of the time series table that you create cannot be the same as the name of an existing data table.
Syntax
public class CreateTimeseriesTableRequest implements Request {
/**The configurations of the time series table. */
private TimeseriesTableMeta timeseriesTableMeta;
}
Parameters
Parameter | Description |
TimeseriesTableMeta | The configurations of the time series table.
|
Example
The following sample code provides an example on how to create a time series table named test_timeseries_table whose data never expires.
private static void createTimeseriesTable(TimeseriesClient client) {
String tableName = "test_timeseries_table";
TimeseriesTableMeta timeseriesTableMeta = new TimeseriesTableMeta(tableName);
int timeToLive = -1;
timeseriesTableMeta.setTimeseriesTableOptions(new TimeseriesTableOptions(timeToLive));
CreateTimeseriesTableRequest request = new CreateTimeseriesTableRequest(timeseriesTableMeta);
client.createTimeseriesTable(request);
}