时间序列
一元时间序列
多元时间序列
可以 aligned
3、“设备”
// 创建一元时间序列的完整语句(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) // 可以指定多元时间序列各物理量的编码(encoding)和压缩方式(compression) // 但是暂不支持指定别名(alias),props, attributes, tags 等 create [aligned] timeseries root.sg1.d1.b ( s3 FLOAT [encoding=RLE] , s4 INT32 [encoding=Grollia] [compression=SNAPPY/GZIP/LZ4/UNCOMPRESSED] ) [compression=SNAPPY]
小括号内未制定compression的列,则采用系统默认配置;
小括号外的compression定义时间列压缩方式和未显式声明的列的压缩方式。
// 插入语句
insert into root.sg.d1(time, b(s1, s2)) values(1,(1,2))
可以扩充一元或多元物理量
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)) values(1,(1,2))
// 服务器需要做类型推断,可能会有额外耗时 void insertAlignedRecord(String prefixPath, long time, List<String> measurements, List<String> values) // 提供数据类型后,服务器不需要做类型推断,可以提高性能 void insertAlignedRecord(String prefixPath, long time, List<String> measurements, List<TSDataType> types, List<Object> values
void insertAlignedRecord( "root.sg.d3.陀螺仪", 1, Arrays.asList("s1", "s2"), Arrays.asList("1", "2") )
insert into root.sg.d3(time, 陀螺仪(s1, s2), GPS(s3, s4)) values(1, (1, 2),(3,4))
// 插入一个 Tablet void insertTablet(Tablet tablet) // 插入多个 Tablet void insertTablets(Map<String, Tablet> tablet)
List<IMeasurementSchema> schemaList = new ArrayList<>(); schemaList.add( new VectorMeasurementSchema( new String[] {"s1", "s2"}, new TSDataType[] {TSDataType.INT64, TSDataType.INT32})); Tablet tablet = new Tablet("root.sg1.d1.GPS", schemaList);
Tablet支持某列的某一行是null?(单元、多元保持统一)