Skip to content

Latest commit

 

History

History
126 lines (98 loc) · 3.25 KB

File metadata and controls

126 lines (98 loc) · 3.25 KB

English | 中文

TsFile Tools 手册

简介

开发

前置条件

构建 Java 版的 TsFile Tools,必须要安装以下依赖:

  1. Java >= 1.8 (1.8, 11 到 17 都经过验证. 请确保设置了环境变量).
  2. Maven >= 3.6 (如果要从源代码编译TsFile).

使用 maven 构建

mvn clean package -P with-java -DskipTests

安装到本地机器

mvn install -P with-java -DskipTests

schema 定义

参数 说明 是否必填 默认值
table_name 表名
time_precision 时间精度(可选值有:ms/us/ns) ms
has_header 是否包含表头 (可选值有:true/false) true
separator 行内分隔符(可选值有:, /tab/ ;) ,
null_format 空值
id_columns 主键列,支持cvs中不存在的列做为层级
time_column 时间列
csv_columns 按照顺序与csv列一一对应

说明:

id_columns 按照顺序进行设置值,支持csv 文件中不存在的列作为层级 例如csv 只有a,b,c,d,time五列则 id_columns a1 default aa a 其中a1 不在csv列,为虚拟列,默认值为aa

csv_columns 之后的内容为值列的定义,每一行的第一个字段为在tsfile中的测点名,第二个字段为类型 当csv中某一列不需要写入 tsfile时,可以设置为 SKIP 例: csv_columns 地区 TEXT, 厂号 TEXT, 设备号 TEXT, SKIP, SKIP, 时间 INT64, 温度 FLOAT, 排量 DOUBLE,

数据示例

csv 文件内容

地区,  厂号, 设备号,  型号, 维修周期, 时间,   温度,   排量
河北, 1001,     1,    10,       1,    1,   80.0, 1000.0
河北, 1001,     1,    10,       1,    4,   80.0, 1000.0
河北, 1002,     7,     5,       2,    1,   90.0, 1200.0

schema 定义

table_name=root.db1
time_precision=ms
has_header=true
separator=,
null_format=\N


id_columns
集团 DEFAULT 大唐
地区
厂号
设备号

time_column=时间

csv_columns
地区 TEXT,
厂号 TEXT,
设备号 TEXT,
SKIP,
SKIP,
时间 INT64,
温度 FLOAT,
排量 DOUBLE,

命令

csv2tsfile.sh --source ./xxx/xxx --target /xxx/xxx --fail_dir /xxx/xxx 
csv2tsfile.bat --source ./xxx/xxx --target /xxx/xxx --fail_dir /xxx/xxx