TsFileWriter implements AutoCloseable { public boolean write(TSRecord record) throws IOException, WriteProcessException { checkIsTimeSeriesExist(record); groupWriters.get(record.deviceId).write(record.time, record.dataPointList); ++recordCount; return checkMemorySizeAndMayFlushChunks(); } TsFileWriter(File file);  TsFileWriter(TsFileIOWriter fileWriter);  TsFileWriter(File file, Schema schema);  TsFileWriter(TsFileOutput output, Schema schema);  TsFileWriter(File file, Schema schema, TSFileConfig conf); protected  TsFileWriter(TsFileIOWriter fileWriter, Schema schema, TSFileConfig conf); void registerDeviceTemplate(String templateName, Map<String, MeasurementSchema> template); void registerDevice(String deviceId, String templateName); void registerTimeseries(Path path, MeasurementSchema measurementSchema); boolean write(TSRecord record); boolean write(Tablet tablet); boolean flushAllChunkGroups(); @Override void close(); TsFileIOWriter getIOWriter(); void writeVersion(long versionPair);  }
@Test public void writeIncorrectTSRecord0() throws IOException, WriteProcessException { TSRecord record = new TSRecord(10002, "d2"); record.addTuple(new IntDataPoint("s1", 5)); try { writer.write(record); } catch (TsFileEncodingException e) { } closeFile(); readNothing(); }
@Test public void writeIncorrectTSRecords() throws IOException, WriteProcessException { for(int i = 2; i < 3; i++) { TSRecord record = new TSRecord(10000 + i, "d"+i); record.addTuple(new IntDataPoint("s1", 5)); try { writer.write(record); } catch (TsFileEncodingException e) { } } closeFile(); readNothing(); }
@Test public void writeIncorrectTSRecord() throws IOException, WriteProcessException { writeTSRecord(); TSRecord record = new TSRecord(10002, "d2"); record.addTuple(new IntDataPoint("s1", 5)); try { writer.write(record); } catch (TsFileEncodingException e) { } closeFile(); readOneRow(); }
@Test public void writeTablet() throws IOException, WriteProcessException { Tablet tablet = new Tablet("d1", Arrays.asList( new MeasurementSchema("s1", TSDataType.FLOAT, TSEncoding.RLE, CompressionType.SNAPPY), new MeasurementSchema("s2", TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY))); tablet.timestamps[0] = 10000; ((float[]) tablet.values[0])[0] = 5.0f; ((int[]) tablet.values[1])[0] = 5; tablet.rowSize = 1; writer.write(tablet); closeFile(); readOneRow(); }
@Test public void writeTablet2() throws IOException, WriteProcessException { Tablet tablet = new Tablet("d1", Arrays.asList( new MeasurementSchema("s1", TSDataType.FLOAT, TSEncoding.RLE, CompressionType.SNAPPY), new MeasurementSchema("s2", TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY))); tablet.timestamps[0] = 10000; ((float[]) tablet.values[0])[0] = 5.0f; tablet.rowSize = 1; writer.write(tablet); closeFile(); readOneRow(0); }