Table of Contents |
---|
时间序列
一元时间序列
多元时间序列
可以aligned
多元时间序列不支持序列嵌套、不支持多时间戳(目前IoTDB均不支持)
多元时间序列中某列的某些行允许有空值(见下面接口描述)。
3、“设备”
...
1、物理量(Measurement,也称工况、字段 field)
物理量,是在实际场景中检测装置所记录的测量信息,且可以按一定规律变换成为电信号或其他所需形式的信息输出并发送给 IoTDB。在 IoTDB 当中,存储的所有数据及路径,都是以物理量为单位进行组织。
2、实体(Entity,也称设备,device)
一个物理实体,是在实际场景中拥有物理量的设备或装置。在 IoTDB 当中,所有的物理量都有其对应的归属实体。
3、存储组(Storage group)
一组物理实体,用户可以将任意前缀路径设置成存储组。
4、数据点(Data point)
一个“时间-值”对。
5、时间序列(一个实体的某个物理量对应一个时间序列,Timeseries,也称测点 meter、时间线 timeline,实时数据库中常被称作标签 tag、参数 parameter)
一个物理实体的某个物理量在时间轴上的记录,是数据点的序列。
6、对齐的时间序列(Aligned timeseries)
对齐的多个时间序列需要同时创建,aligned可以删除其中某列,但不能新增列。
7、物理量模板(Schema template)
实际应用中有许多实体所采集的物理量相同,即具有相同的工况名称和类型,可以声明一个物理量模板来定义可采集的物理量集合。在实践中,物理量模板的使用可帮助减少元数据的资源占用。
// 创建一元时间序列的完整语句(v0.12及之前) create timeseries root.turbine.d1.s2 with datatype=FLOAT, encoding=RLE, compression=SNAPPY, tags(tag1=v1, tag2=v2), attributes(attr1=v1, attr2=v2) // v0.13之后,创建语句的新语法,示例: create timeseries root.sg.d3.s1 FLOAT [encoding=RLE] [compression=SNAPPY] [tags(tag1=v1, tag2=v2)] [attributes(attr1=v1, attr2=v2)] create timeseries root.sg.d3.s2 FLOAT [encoding=RLE] [compression=SNAPPY] [tags(tag1=v1, tag2=v2)] [attributes(attr1=v1, attr2=v2)]
// 插入语句 insert into root.sg.d3(time, s1) values(1,1)
insert into root.sg.d3(time, s1, s2) values(1,1,2)
// 注意:多元的时间序列的压缩方式必须相同
create [aligned] timeseries root.sg1.d1.电表(s1 FLOAT, s2 INT32)
...
create timeseries root.sg1.d1.c FLOAT
// 创建语句
create [aligned] timeseries root.sg.d1.(s1 FLOAT, s2 INT32)
// 插入语句
insert into root.sg.d1(time, (s1, s2)) values(1, (1,2))
不能
// 创建语句 create [aligned] timeseries root.sg.d3.陀螺仪(s1 FLOAT, s2 INT32) create [aligned] timeseries root.sg.d3.GPS(s3 FLOAT, s4 INT32) // 插入语句 insert into root.sg.d3(time, 陀螺仪(s1, s2), GPS(s3, s4)) values(1, (1, 2),(3,4)) insert into root.sg.d3(time, 陀螺仪(s1, s2)) values(1, (1, 2)) // 查询语句 select s1,s2 from root.sg.d3.陀螺仪 select * from root.sg.d3.陀螺仪 select 陀螺仪.* from root.sg.d3 select 陀螺仪.s1 from root.sg.d3 select d3.* from root.sg
...
create timeseries root.sg.d3.s3 FLOAT
// 创建语句 create [aligned] timeseries root.sg.d4.GPS(s3 FLOAT, s4 INT32) create timeseries root.sg.d4.s5 FLOAT // 插入语句 insert into root.sg.d3(time, GPS(s3, s4), s5) values(1, (3,4), 5)
// 创建多元时间序列 void createAlignedTimeseries( String prefixPath, // "root.sg.d1.陀螺仪" List<String> measurements, List<TSDataType> dataTypes, List<TSEncoding> encodings, CompressionType compressor, List<String> measurementAliasList );
...
insert into root.sg.d3(time, 陀螺仪(s1, s2), GPS(s3, s4)) values(1, (1, 2),(3,4))
...