private static void query4Redirect()
      throws IoTDBConnectionException, StatementExecutionException {
    String selectPrefix = "select * from root.redirect";
    for (int i = 0; i < 6; i++) {
      try (SessionDataSet dataSet =
          sessionEnableRedirect.executeQueryStatement(selectPrefix + i + ".d1")) {

        System.out.println(dataSet.getColumnNames());
        dataSet.setFetchSize(1024); // default is 10000
        while (dataSet.hasNext()) {
          System.out.println(dataSet.next());
        }
      }
    }

    for (int i = 0; i < 6; i++) {
      try (SessionDataSet dataSet =
          sessionEnableRedirect.executeQueryStatement(
              selectPrefix + i + ".d1 where time >= 1 and time < 10")) {

        System.out.println(dataSet.getColumnNames());
        dataSet.setFetchSize(1024); // default is 10000
        while (dataSet.hasNext()) {
          System.out.println(dataSet.next());
        }
      }
    }

    for (int i = 0; i < 6; i++) {
      try (SessionDataSet dataSet =
          sessionEnableRedirect.executeQueryStatement(
              selectPrefix + i + ".d1 where time >= 1 and time < 10 align by device")) {

        System.out.println(dataSet.getColumnNames());
        dataSet.setFetchSize(1024); // default is 10000
        while (dataSet.hasNext()) {
          System.out.println(dataSet.next());
        }
      }
    }

    for (int i = 0; i < 6; i++) {
      try (SessionDataSet dataSet =
          sessionEnableRedirect.executeQueryStatement(
              selectPrefix
                  + i
                  + ".d1 where time >= 1 and time < 10 and root.redirect"
                  + i
                  + ".d1.s1 > 1")) {
        System.out.println(dataSet.getColumnNames());
        dataSet.setFetchSize(1024); // default is 10000
        while (dataSet.hasNext()) {
          System.out.println(dataSet.next());
        }
      }
    }
  }
This example shows how to insert data of TSDataType.TEXT. You can use the session interface to
write data of String type or Binary type.
example/session/src/main/java/org/apache/iotdb/SessionExample.java