Hummer TimeSeries DB 优势功能(操作)介绍
Hummer TimeSeriesDB 针对时序数据存储和查询进行了特色优化,尤其适合时序数据高速写入、按时段(以及key)进行快速查询、数据量估算、数据快速删除 。 接下来来我们就查询优势场景进行简要介绍(我们已Demo中tpass表为例说明——该表时间跨度1年、pkt 格式)。
给定时段查询
按时间范围查询会利用到时序引擎数序按时间排序优势—— 数据按时间聚集,顺序连续扫描速度最优。
如:
select count(*) from tpass where
pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-02-05 00:00:00') * 1000
给定时段聚合计算
按时间段聚合雨按时间段查询类似
select avg(speed) from tpass where
pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-01-05 00:00:00') * 1000
给定时段时间正序查询
存储按照时间有序,所以获取时段内最老记录很高效
select * from tpass orderby pass_time limit 10
给定时段时间倒序查询
存储按照时间有序,所以获取时段内最新记录很高效
select * from tpass orderby pass_time desc limit 10
给定时段精确key确查询
PKT格式对于给定key精确检索效率很高 —— key在时段内被有序聚集
select count(*) from tpass where car_card_num='京A27TFG' and pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-02-01 00:00:00') * 1000
给定时段模糊key前缀查询
PKT格式对于前缀key模糊检索效率也很高—— key在时段内被有序聚集
select count(*) from tpass where car_card_num like '京A2%' and pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-02-01 00:00:00') * 1000
给定时段精确key聚合计算
select max(speed) from tpass where car_card_num like'京A27TFG' and pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-02-01 00:00:00') * 1000
给定时段模糊key前缀聚合计算
select max(speed) from tpass where car_card_num like '京A2%' and pass_time > unix_timestamp('2014-01-01 00:00:00') * 1000 and pass_time < unix_timestamp('2014-02-01 00:00:00') * 1000
给定时段数据记录快速统计/记录大小快速估计(所谓估计是近似估计——如果要准确估计需进行一次整理)
Hummer TimeSeries 支持快速按时间段计算数据量:选择时间起始和结束范围,执行统计操作(下图分别是全年和半年的数据统计结果)
按时段快速删除数据
Hummer TimeSeries 支持按时间段快速删除数据:选定时间起始和结束范围,执行清理操作(再执行整理和统计操作验证结果)
数据随机乱序写入
insert into tpass values('TESTCAR',1500000000000,'aaaa','bbbb',1,'黑','卡车',50,'宝马','轿车','超速','1','京','1')
数据更新、删除——记录见 《Hummer TimeSeries DB 中关于RowId 的使用》 一文
动态建表
create table t_pass ( car_card_num string comment 'nullable=false', pass_time bigint comment 'nullable=false', toll_gate_red_id string comment 'length=8,nullable=false', road_id string comment 'length=6, car_card_type int comment 'nullable=false', car_card_color string comment 'length=3, car_type string comment 'length=6, speed int comment 'nullable=false', brand string comment 'length=6, car_sharp string comment 'length=6, car_color string comment 'length=3, paccancy_type string comment 'length=6, run_direct string comment 'length=1, car_card_loc string comment 'length=3, execute_state string comment 'length=1,nullable=false' ) with serdeproperties("hummer.db.columns.mapping" = "key=car_card_num,timestamp=pass_time") stored as HUMMERFILE TBLPROPERTIES("zkAddress"="10.0.11.120:2181","tablename"="t_pass","keyType"="pkt"); Schema属性有定长,变长,可空等; 表属性有分片数"FragmentSize"=" ?"(默认为没个磁盘一分片)、副本数"ReplicSize"=" ?"(默认为三) key 属性有唯一和非唯一两种 —— key=xxx代表唯一,index=xxx代表非唯一
动态删表 drop tablet_pass;
Hummer TimeSeries DB Dock DEMO 介绍文章和下载见
http://blog.csdn.net/kanghua/article/details/44653149
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |