1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! This is a not yet feature complete Writer for TsFiles Version 3 (as defined from the Apache IoTDB Project).
//! Currently not all features of TsFiles are supported.
//! Most notably:
//!
//! * No Aligned Chunks can be written
//! * Not all Encodings are available
//! * Not all DataTypes are supported
//! * Not all Compression Types are supported
//!
//! But generally, the TsFiles written with this client are 100% compatible with TsFiles written in Java.
//!
//! ## Quickstart
//!
//! To write a TsFile just do something like
//!
//! ```
//! use tsfile_writer::writer::tsfile_writer::TsFileWriter;
//! use tsfile_writer::writer::IoTDBValue;
//! use tsfile_writer::writer::tsfile_writer::DataPoint;
//! use tsfile_writer::writer::schema::TsFileSchemaBuilder;
//! use tsfile_writer::writer::schema::DeviceBuilder;
//! use tsfile_writer::writer::TSDataType;
//! use tsfile_writer::writer::encoding::TSEncoding;
//! use tsfile_writer::writer::compression::CompressionType;
//!
//! // Create the Schema
//! // Two devices with two sensors each
//! let schema = TsFileSchemaBuilder::new()
//! .add(
//! "d1",
//! DeviceBuilder::new()
//! .add(
//! "s1",
//! TSDataType::INT64,
//! TSEncoding::PLAIN,
//! CompressionType::UNCOMPRESSED,
//! )
//! .add(
//! "s2",
//! TSDataType::FLOAT,
//! TSEncoding::PLAIN,
//! CompressionType::UNCOMPRESSED,
//! )
//! .build(),
//! )
//! .add(
//! "d2",
//! DeviceBuilder::new()
//! .add(
//! "s1",
//! TSDataType::INT64,
//! TSEncoding::PLAIN,
//! CompressionType::UNCOMPRESSED,
//! )
//! .add(
//! "s2",
//! TSDataType::FLOAT,
//! TSEncoding::PLAIN,
//! CompressionType::UNCOMPRESSED,
//! )
//! .build(),
//! )
//! .build();
//!
//! // Create the writer
//! let mut writer = TsFileWriter::new(
//! "target/benchmark2.tsfile",
//! schema,
//! Default::default(),
//! )
//! .unwrap();
//!
//! // Write multiple timeseries at once
//! writer.write_many("d1",1, vec![
//! DataPoint::new("s1", IoTDBValue::LONG(13)),
//! DataPoint::new("s2", IoTDBValue::FLOAT(13.0 as f32)),
//! ]);
//!
//! // Write single series
//! writer.write("d2", "s1", 1, IoTDBValue::LONG(14));
//! writer.write("d2", "s2", 1, IoTDBValue::FLOAT(14.0 as f32));
//! ```