The example is to show how to write and read a TsFile File.
<dependencies> <dependency> <groupId>org.apache.tsfile</groupId> <artifactId>tsfile</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> </dependencies>
This class is to show how to write a TsFile. It provided two ways:
The first one is using a JSON string for measurement(s). The JSON string is an array of JSON objects(schema). The object must include the measurement_id, datatype, encoding, and compressor.
An example JSON string is provided in the comments in the method
public static void tsFileWriteWithJson() throws IOException,WriteProcessException
It uses this interface
public void addMeasurementByJson(JSONObject measurement) throws WriteProcessException
An alternative way is to add these measurements directly(manually) by the second interface:
public void addMeasurement(MeasurementSchema measurementSchema) throws WriteProcessException
The method
public static void tsFileWriteDirect() throws IOException,WriteProcessException
shows how to use that interface.
Note that the measurements in the two methods are the same therefore there output TsFile should also be identical.
This class is to show how to read TsFile file named “testDirect.tsfile”.
The TsFile file “testDirect.tsfile” is generated from class TsFileWrite.
It generates the same TsFile(testDirect.tsfile and testWithJson.tsfile) file by two different ways
Run TsFileWrite to generate the testDirect.tsfile first
This class is to show the structure of a TsFile.
For detail, please refer to https://github.com/apache/iotdb/blob/master/tsfile/README.md.