Timestream数据存储包含元数据表和数据表。数据表可以有多个,您可以根据自身的场景需求将数据写入到不同的表中,例如按数据精度分表。元数据表只能有一个,所有数据表的元数据信息全部记录到同一张表中。Timestream提供了元数据表和数据表的创建和删除功能。

元数据表

创建元数据表时可以预定义需要建索引的Attributes以及对应的索引属性和类型。索引类型支持LONG、DOUBLE、BOOLEAN、KEYWORD、GEO_POINT等类型,属性包含Index、Store和Array,其含义与多元索引相同。

说明 没有指定索引类型的Attributes不会创建索引,后续时间线检索时也就不能指定这类Attributes作为查询条件。

操作步骤及示例代码如下。

  1. 创建不包含任何Attributes索引的元数据表。
            db.createMetaTable();
  2. 创建指定Attributes索引的元数据表。
            List<AttributeIndexSchema> indexSchemas = new ArrayList<AttributeIndexSchema>();
            indexSchemas.add(new AttributeIndexSchema("owner", AttributeIndexSchema.Type.KEYWORD).setIsArray(true));
            indexSchemas.add(new AttributeIndexSchema("number", AttributeIndexSchema.Type.LONG));
            indexSchemas.add(new AttributeIndexSchema("score", AttributeIndexSchema.Type.DOUBLE));
            indexSchemas.add(new AttributeIndexSchema("succ", AttributeIndexSchema.Type.BOOLEAN));
            indexSchemas.add(new AttributeIndexSchema("loc", AttributeIndexSchema.Type.GEO_POINT));
            db.createMetaTable(indexSchemas);
  3. 删除元数据表。
            db.deleteMetaTable();

数据表

操作步骤及示例代码如下。

  1. 创建数据表。
            db.createDataTable("datatable");
  2. 删除数据表。
            db.deleteDataTable("datatable");