tsfile-cli
Use specifically for the project's C++ `tsfile-cli` in cpp/tools: inspect, preview, export, or create an Apache TsFile; report metadata or per-series counts; or use its explicit single-table CSV write command.
- License 许可
- Apache-2.0
- 所属仓库
- apache/tsfile
- 最近更新
- 2026-11-11
- Stars
- ★ 211
- Forks
- 112
01 前言 Front Matter
- name
- tsfile-cli
- description
- Use specifically for the project's C++ `tsfile-cli` in cpp/tools: inspect, preview, export, or create an Apache TsFile; report metadata or per-series counts; or use its explicit single-table CSV write command.
02 资源文件 4
- 参考文档agents/openai.yaml158 B
- 参考文档references/commands.md2.6 KB
- 参考文档references/errors.md1.7 KB
- 参考文档references/examples.md1.6 KB
03 SKILL.md 正文
tsfile-cli
Single pipe-friendly C++ binary to inspect, read, export, and create .tsfile
files. Source cpp/tools/. Result data goes to stdout except export,
sketch -o, and write; diagnostics go to stderr.
Reference files:
references/commands.md: command syntax and result fields.references/errors.md: exit-code and failure-handling rules.references/examples.md: reviewed command recipes.
Scope
Use this skill only for the C++ tsfile-cli binary. Route Java
csv2tsfile/parquet2tsfile/arrow2tsfile and table point-count metadata
checks or backfill to the top-level tsfile skill when it is installed.
The names overlap but the semantics do not: tsfile-cli count is a read-only
per-series report, not the Java table point-count property tool. tsfile-cli write is the C++ binary's narrow one-file/stream, one-table CSV import; it
does not replace the Java batch and format-aware import tools.
Binary
- Name
tsfile-cli(CMake targettsfile_cli). Find:ls cpp/build/*/bin/tsfile-cli. - Build only if missing:
cd cpp && bash build.sh -t=Debug.
Read
tsfile-cli <cmd> [opts] <file.tsfile> · tsfile-cli --help | --version | help
| cmd | output | scans pages |
|---|---|---|
ls |
model,object rows for tree devices or table names |
no |
schema |
model,object,column,category,data_type,encoding,compression |
no |
meta |
size_bytes,format_version,model |
no |
stats |
FIELD statistics with null counts and source | maybe |
count |
object/column counts; no summary row | maybe |
head |
first N rows (default 10, -n) |
yes |
cat |
all matching rows (streamed; table format buffers) |
yes |
sketch |
physical layout text from the bound printSketch behavior |
no FIELD decode |
export |
writes one object file or a numbered multi-object directory | yes |
Prefer metadata verbs (ls/schema/meta/stats/count) before row verbs so the
file model, scope, and columns are known.
For head and cat, omit -d/-t only when the selected model has exactly one
accessible object. Multi-object files require explicit scope. export always
requires explicit scope.
opts: -f table|ndjson|csv (default table)
-d <device> | -t <table> (mutually exclusive)
-m <column> repeat for projection or metadata filtering; no comma lists
-n N · --offset N · --start <int64> · --end <int64> for head/cat/export
--tag-filter C OP [V] where OP=eq|neq|regexp|is-null|not-null
--tag-match all|any when two or more tag filters are present
ndjson=one JSON object per line · csv=RFC 4180 with header · INT64/TIMESTAMP as decimal strings
exit: 0 ok · 1 usage · 2 file open/corrupt · 3 query/runtime
B=cpp/build/Debug/bin/tsfile-cli
$B meta data.tsfile; $B count -t table1 -f csv data.tsfile
$B cat -t table1 --tag-filter device eq dev_1 -m temp -f ndjson data.tsfile
$B cat -m temp --start 1700000000000 -f csv data.tsfile 2>/dev/null | head
Write
tsfile-cli write --table <name> (--tag <name> STRING)* (--field <name> <TYPE>)+ [--encoding <TYPE> <ENC>] [--compression <TYPE> <COMP>] (-i <input.csv>|--stdin) -o <out.tsfile> [-v]
Creates a new single-table, table-model file from strict CSV. The target must not already exist; the command never creates tree-model TsFiles and never modifies an existing TsFile.
TYPE ∈ { BOOLEAN, INT32, INT64, FLOAT, DOUBLE, STRING, TEXT, TIMESTAMP, DATE, BLOB }
ENC ∈ bound TsFile encodings such as PLAIN, TS_2DIFF, GORILLA, DICTIONARY
COMP ∈ UNCOMPRESSED, SNAPPY, GZIP, LZO, LZ4, ZSTD, LZMA2
- CSV must contain a unique header with
timeand exactly the declared TAG/FIELD names; rows are mapped by header name, not physical column order. --encodingand--compressionare keyed by declared data type and apply to all declared columns of that type.DATEcells areYYYY-MM-DD;TIMESTAMPand rowtimeuse strict decimal int64.- timestamps must be strictly increasing per device (device = tag-column values); rows for different tags may interleave/reuse timestamps. Out-of-order input → error with line number.
- A failed import deletes its partial output; success is silent unless
-vis used. -vwrites one post-commit summary to stderr:created model=table object=<table> rows=<n> output=<path>plus one line per column with resolved physical settings.- exit:
1usage/parameter error ·2CSV/input problem ·3target/write/commit failure.
printf 'time,id1,s1\n0,dev,0\n1,dev,10\n' \
| tsfile-cli write --table t1 --tag id1 STRING --field s1 INT64 --stdin -o out.tsfile
tsfile-cli count -f csv out.tsfile
Tree-model / JSON / programmatic writes → C++ SDK cpp/examples/cpp_examples/demo_write.cpp
(TsFileTableWriter/TsFileWriter + Tablet); Java/Python writers under java/, python/.
Caveats
head/cat/exportdecode pages; nonzero exit means any produced stdout or files are not complete results.- Table results always include all TAG columns before selected FIELD columns.
sketchfollows the bound TsFileprintSketchtext and does not support-f.
04 同仓库更多 Skills
tsfile
Work with the current Apache TsFile SDKs, tools, and file format. Use for Java, Python, C++, or C reads and writes; Python DataFrame and Arrow batches; Java CSV/Parquet/Arrow import; file properties; TAG filters; query-by-row and metadata APIs; C++ incomplete-writer recovery and append; static/shared C++ builds; parallel and TsBlock writes; encoding/compression factories; schema design; performance; and cross-language integration. Route operations specific to the C++ tsfile-cli binary to the sibling tsfile-cli skill.
tsfile-cli
Use specifically for the project's C++ `tsfile-cli` in cpp/tools: inspect, preview, export, or create an Apache TsFile; report metadata or per-column counts; or use its explicit single-table CSV write command.