class TsFileWriter implements AutoCloseable {

  public boolean flushAllChunkGroups() throws IOException {
    if (recordCount > 0) {
      for (Map.Entry<String, IChunkGroupWriter> entry : groupWriters.entrySet()) {
        long pos = fileWriter.getPos();
        String deviceId = entry.getKey();
        IChunkGroupWriter groupWriter = entry.getValue();
        fileWriter.startChunkGroup(deviceId);
        long dataSize = groupWriter.flushToFileWriter(fileWriter);
        if (fileWriter.getPos() - pos != dataSize) {
          throw new IOException(
              String.format(
                  "Flushed data size is inconsistent with computation! Estimated: %d, Actual: %d",
                  dataSize, fileWriter.getPos() - pos));
        }
        fileWriter.endChunkGroup();
      }
      reset();
    }
    return false;
  }

  public  TsFileWriter(File file);
  public  TsFileWriter(TsFileIOWriter fileWriter);
  public  TsFileWriter(File file, Schema schema);
  public  TsFileWriter(TsFileOutput output, Schema schema);
  public  TsFileWriter(File file, Schema schema, TSFileConfig conf);
  protected  TsFileWriter(TsFileIOWriter fileWriter, Schema schema, TSFileConfig conf);

}