All Products
Search
Document Center

Tablestore:Delete time series metadata

Last Updated:Feb 20, 2024

You can call the DeleteTimeseriesMeta operation to delete the metadata of multiple time series at a time.

Note

For more information, see DeleteTimeseriesMeta.

Prerequisites

  • Time series data is written to the time series table from which you want to query data. For more information, see Write time series data.

  • A TimeseriesClient instance is initialized. For more information, see Initialize a client.

Parameters

A time series identifier is used to identify a time series. You can specify multiple time series identifiers to delete the metadata of multiple time series. The following table describes the parameter.

Parameter

Description

timeseriesKey

The identifier of the time series. The identifier includes the following parameters:

  • measurementName: the measurement name of the time series.

  • dataSource: the data source of the time series. You can leave this parameter empty.

  • tags: the tags of the time series. The value of this parameter is key-value pairs of the STRING type.

Examples

The following code provides an example on how to delete the metadata of some time series in a time series table.

private static void deleteTimeseriesMeta(TimeseriesClient client) {
    List<TimeseriesKey> timeseriesKeyList = new ArrayList<TimeseriesKey>();
    for (int i = 0; i < 10; i++) {
        Map<String, String> tags = new HashMap<String, String>();
        tags.put("region", "hangzhou");
        tags.put("os", "Ubuntu16.04");
        // Construct a time series identifier. 
        TimeseriesKey timeseriesKey = new TimeseriesKey("cpu", "host_" + i, tags);
        timeseriesKeyList.add(timeseriesKey);
    }
    // Specify the name of the time series table. 
    String tableName = "<TIME_SERIES_TABLE>";
    DeleteTimeseriesMetaRequest deleteTimeseriesMetaRequest = new DeleteTimeseriesMetaRequest(tableName);
    deleteTimeseriesMetaRequest.setTimeseriesKeys(timeseriesKeyList);
    DeleteTimeseriesMetaResponse deleteTimeseriesMetaResponse = client.deleteTimeseriesMeta(deleteTimeseriesMetaRequest);
    // Check whether the metadata of the time series is deleted. 
    if (!deleteTimeseriesMetaResponse.isAllSuccess()) {
        for (DeleteTimeseriesMetaResponse.FailedRowResult failedRowResult : deleteTimeseriesMetaResponse.getFailedRows()) {
            System.out.println(failedRowResult.getIndex());
            System.out.println(failedRowResult.getError());
        }
    }
}