public static InsertTabletStatement createStatement(TSInsertTabletReq insertTabletReq)
      throws IllegalPathException {
    final long startTime = System.nanoTime();
    // construct insert statement
    InsertTabletStatement insertStatement = new InsertTabletStatement();
    insertStatement.setDevicePath(
        DEVICE_PATH_CACHE.getPartialPath(insertTabletReq.getPrefixPath()));
    insertStatement.setMeasurements(insertTabletReq.getMeasurements().toArray(new String[0]));
    long[] timestamps =
        QueryDataSetUtils.readTimesFromBuffer(insertTabletReq.timestamps, insertTabletReq.size);
    if (timestamps.length != 0) {
      TimestampPrecisionUtils.checkTimestampPrecision(timestamps[timestamps.length - 1]);
    }
    insertStatement.setTimes(timestamps);
    insertStatement.setColumns(
        QueryDataSetUtils.readTabletValuesFromBuffer(
            insertTabletReq.values,
            insertTabletReq.types,
            insertTabletReq.types.size(),
            insertTabletReq.size));
    insertStatement.setBitMaps(
        QueryDataSetUtils.readBitMapsFromBuffer(
                insertTabletReq.values, insertTabletReq.types.size(), insertTabletReq.size)
            .orElse(null));
    insertStatement.setRowCount(insertTabletReq.size);
    TSDataType[] dataTypes = new TSDataType[insertTabletReq.types.size()];
    for (int i = 0; i < insertTabletReq.types.size(); i++) {
      dataTypes[i] = TSDataType.deserialize((byte) insertTabletReq.types.get(i).intValue());
    }
    insertStatement.setDataTypes(dataTypes);
    insertStatement.setAligned(insertTabletReq.isAligned);
    insertStatement.setWriteToTable(insertTabletReq.isWriteToTable());
    if (insertTabletReq.isWriteToTable()) {
      if (!insertTabletReq.isSetColumnCategories()
          || insertTabletReq.getColumnCategoriesSize() != insertTabletReq.getMeasurementsSize()) {
        throw new IllegalArgumentException(
            "Missing or invalid column categories for table " + "insertion");
      }
      TsTableColumnCategory[] columnCategories =
          new TsTableColumnCategory[insertTabletReq.columnCategories.size()];
      for (int i = 0; i < columnCategories.length; i++) {
        columnCategories[i] =
            TsTableColumnCategory.fromTsFileColumnCategory(
                ColumnCategory.values()[insertTabletReq.columnCategories.get(i).intValue()]);
      }
      insertStatement.setColumnCategories(columnCategories);
    }
    PERFORMANCE_OVERVIEW_METRICS.recordParseCost(System.nanoTime() - startTime);
    return insertStatement;
  }
Convert SQL and RPC requests to {@link Statement}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/StatementGenerator.java