private void splitColToDeviceAndMeasurement()

in backend/src/main/java/org/apache/iotdb/admin/tool/ImportCsv.java [281:325]


  private void splitColToDeviceAndMeasurement(
      String col,
      Map<String, List<Integer>> devicesToPositions,
      Map<String, List<String>> devicesToMeasurements,
      int position)
      throws BaseException {
    if (col.length() > 0) {
      if (col.charAt(col.length() - 1) == TsFileConstant.DOUBLE_QUOTE) {
        int endIndex = col.lastIndexOf('"', col.length() - 2);
        // if a double quotes with escape character
        while (endIndex != -1 && col.charAt(endIndex - 1) == '\\') {
          endIndex = col.lastIndexOf('"', endIndex - 2);
        }
        if (endIndex != -1 && (endIndex == 0 || col.charAt(endIndex - 1) == '.')) {
          putDeviceAndMeasurement(
              col.substring(0, endIndex - 1),
              col.substring(endIndex),
              devicesToPositions,
              devicesToMeasurements,
              position);
        } else {
          throw new BaseException(
              ErrorCode.FILE_FIRST_LINE_ILLEGAL, ErrorCode.FILE_FIRST_LINE_ILLEGAL_MSG);
        }
      } else if (col.charAt(col.length() - 1) != TsFileConstant.DOUBLE_QUOTE
          && col.charAt(col.length() - 1) != TsFileConstant.PATH_SEPARATOR_CHAR) {
        int endIndex = col.lastIndexOf(TsFileConstant.PATH_SEPARATOR_CHAR);
        if (endIndex < 0) {
          putDeviceAndMeasurement("", col, devicesToPositions, devicesToMeasurements, position);
        } else {
          putDeviceAndMeasurement(
              col.substring(0, endIndex),
              col.substring(endIndex + 1),
              devicesToPositions,
              devicesToMeasurements,
              position);
        }
      } else {
        throw new BaseException(
            ErrorCode.FILE_FIRST_LINE_ILLEGAL, ErrorCode.FILE_FIRST_LINE_ILLEGAL_MSG);
      }
    } else {
      putDeviceAndMeasurement("", col, devicesToPositions, devicesToMeasurements, position);
    }
  }