public static void writeWithTsRecord()

in java/tsfile/src/main/java/org/apache/tsfile/utils/TsFileGeneratorUtils.java [57:108]


  public static void writeWithTsRecord(
      TsFileWriter tsFileWriter,
      String deviceId,
      List<IMeasurementSchema> schemas,
      long rowSize,
      long startTime,
      long startValue,
      boolean isAligned)
      throws IOException, WriteProcessException {
    for (long time = startTime; time < rowSize + startTime; time++, startValue++) {
      // construct TsRecord
      TSRecord tsRecord = new TSRecord(deviceId, time);
      for (IMeasurementSchema schema : schemas) {
        DataPoint dPoint;
        switch (schema.getType()) {
          case INT64:
          case TIMESTAMP:
            dPoint = new LongDataPoint(schema.getMeasurementName(), startValue);
            break;
          case INT32:
          case DATE:
            dPoint = new IntDataPoint(schema.getMeasurementName(), (int) startValue);
            break;
          case DOUBLE:
            dPoint = new DoubleDataPoint(schema.getMeasurementName(), (double) startValue);
            break;
          case FLOAT:
            dPoint = new FloatDataPoint(schema.getMeasurementName(), (float) startValue);
            break;
          case BOOLEAN:
            dPoint = new BooleanDataPoint(schema.getMeasurementName(), true);
            break;
          case TEXT:
          case BLOB:
          case STRING:
          default:
            dPoint =
                new StringDataPoint(
                    schema.getMeasurementName(),
                    new Binary(String.valueOf(startValue), TSFileConfig.STRING_CHARSET));
            break;
        }
        tsRecord.addTuple(dPoint);
      }
      // write
      if (isAligned) {
        tsFileWriter.writeRecord(tsRecord);
      } else {
        tsFileWriter.writeRecord(tsRecord);
      }
    }
  }