跳至主要內容

...大约 3 分钟

自动创建元数据

自动创建元数据指的是根据写入数据的特征自动创建出用户未定义的时间序列,
这既能解决海量序列场景下设备及测点难以提前预测与建模的难题,又能为用户提供开箱即用的写入体验。

自动创建存储组的元数据

  • enable_auto_create_schema
名字enable_auto_create_schema
描述是否开启自动创建元数据功能
类型boolean
默认值true
改后生效方式重启服务生效
  • default_storage_group_level
名字default_storage_group_level
描述指定存储组在时间序列所处的层级,默认为第 1 层(root为第 0 层)
类型int
默认值1
改后生效方式仅允许在第一次启动服务前修改

以下图为例:

  • 当 default_storage_group_level=1 时,将使用 root.turbine1 和 root.turbine2 作为存储组。

  • 当 default_storage_group_level=2 时,将使用 root.turbine1.d1、root.turbine1.d2、root.turbine2.d1 和 root.turbine2.d2 作为存储组。

auto create storage group example

自动创建序列的元数据(前端指定数据类型)

  • 用户在写入时精确指定数据类型:

    • Session中的insertTablet接口。
    • Session中带有TSDataType的insert接口。
      public void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, Object... values);
      public void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList);
      
    • ......
  • 插入数据的同时自动创建序列,效率较高。

自动创建序列的元数据(类型推断)

  • 在写入时直接传入字符串,数据库推断数据类型:

    • CLI的insert命令。
    • Session中不带有TSDataType的insert接口。
      public void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values);
      public void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList);
      
    • ......
  • 由于类型推断会增加写入时间,所以通过类型推断自动创建序列元数据的效率要低于通过前端指定数据类型自动创建序列元数据,建议用户在可行时先选用前端指定数据类型的方式自动创建序列的元数据。

类型推断

数据(String)字符串格式iotdb-engine.properties配置项默认值
truebooleanboolean_string_infer_typeBOOLEAN
1integerinteger_string_infer_typeFLOAT
17000000(大于 2^24 的整数)integerlong_string_infer_typeDOUBLE
1.2floatingfloating_string_infer_typeFLOAT
NaNnannan_string_infer_typeDOUBLE
'I am text'text
  • 可配置的数据类型包括:BOOLEAN, INT32, INT64, FLOAT, DOUBLE, TEXT

  • long_string_infer_type 配置项的目的是防止使用 FLOAT 推断 integer_string_infer_type 而造成精度缺失。

编码方式

数据类型iotdb-engine.properties配置项默认值
BOOLEANdefault_boolean_encodingRLE
INT32default_int32_encodingRLE
INT64default_int64_encodingRLE
FLOATdefault_float_encodingGORILLA
DOUBLEdefault_double_encodingGORILLA
TEXTdefault_text_encodingPLAIN
  • 可配置的编码方式包括:PLAIN, RLE, TS_2DIFF, GORILLA, DICTIONARY

  • 数据类型与编码方式的对应关系详见 编码方式

Copyright © 2024 The Apache Software Foundation.
Apache IoTDB, IoTDB, Apache, the Apache feather logo, and the Apache IoTDB project logo are either registered trademarks or trademarks of The Apache Software Foundation in all countries

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.