You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ge...@apache.org on 2020/04/21 05:59:19 UTC

[incubator-iotdb] branch IOTDB-537 created (now 60137fa)

This is an automated email from the ASF dual-hosted git repository.

geniuspig pushed a change to branch IOTDB-537
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 60137fa  update client.

This branch includes the following new commits:

     new 60137fa  update client.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: update client.

Posted by ge...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

geniuspig pushed a commit to branch IOTDB-537
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 60137fa2767f8f9bacb6f69d3bddcf0d8d57f416
Author: zhutianci <zh...@gmail.com>
AuthorDate: Tue Apr 21 13:59:01 2020 +0800

    update client.
---
 .../org/apache/iotdb/client/AbstractClient.java    | 83 +++++++++++++++-------
 .../org/apache/iotdb/db/service/TSServiceImpl.java |  2 +-
 2 files changed, 60 insertions(+), 25 deletions(-)

diff --git a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
index 3da35d7..cf95955 100644
--- a/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
+++ b/client/src/main/java/org/apache/iotdb/client/AbstractClient.java
@@ -25,6 +25,7 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.iotdb.exception.ArgsErrorException;
 import org.apache.iotdb.jdbc.IoTDBConnection;
+import org.apache.iotdb.jdbc.IoTDBNonAlignQueryResultSet;
 import org.apache.iotdb.jdbc.IoTDBQueryResultSet;
 import org.apache.iotdb.service.rpc.thrift.ServerProperties;
 import org.apache.iotdb.tool.ImportCsv;
@@ -70,7 +71,7 @@ public abstract class AbstractClient {
   static final String MAX_PRINT_ROW_COUNT_ARGS = "maxPRC";
   private static final String MAX_PRINT_ROW_COUNT_NAME = "maxPrintRowCount";
   static final String RPC_COMPRESS_ARGS = "c";
-  static final String RPC_COMPRESS_NAME = "rpcCompressed";
+  private static final String RPC_COMPRESS_NAME = "rpcCompressed";
   static final String SET_MAX_DISPLAY_NUM = "set max_display_num";
   static final String SET_TIMESTAMP_DISPLAY = "set time_display_type";
   static final String SHOW_TIMESTAMP_DISPLAY = "show time_display_type";
@@ -582,40 +583,74 @@ public abstract class AbstractClient {
    */
   private static List<List<String>> cacheResult(ResultSet resultSet, List<Integer> maxSizeList,
       int columnCount, ResultSetMetaData resultSetMetaData, ZoneId zoneId) throws SQLException {
-
-    boolean printTimestamp = !((IoTDBQueryResultSet) resultSet).isIgnoreTimeStamp();
     List<List<String>> lists = new ArrayList<>(columnCount);
-    for (int i = 1; i <= columnCount; i++) {
-      List<String> list = new ArrayList<>(maxPrintRowCount + 1);
-      list.add(resultSetMetaData.getColumnLabel(i));
-      lists.add(list);
-      maxSizeList.add(resultSetMetaData.getColumnLabel(i).length());
+    if( resultSet instanceof  IoTDBQueryResultSet) {
+      for (int i = 1; i <= columnCount; i++) {
+        List<String> list = new ArrayList<>(maxPrintRowCount + 1);
+        list.add(resultSetMetaData.getColumnLabel(i));
+        lists.add(list);
+        maxSizeList.add(resultSetMetaData.getColumnLabel(i).length());
+      }
+    } else {
+      for (int i = 1; i <= columnCount; i+=2) {
+        List<String> timeList = new ArrayList<>(maxPrintRowCount + 1);
+        timeList.add(resultSetMetaData.getColumnLabel(i).substring(0, TIMESTAMP_STR.length()));
+        lists.add(timeList);
+        List<String> valueList = new ArrayList<>(maxPrintRowCount + 1);
+        valueList.add(resultSetMetaData.getColumnLabel(i+1));
+        lists.add(valueList);
+        maxSizeList.add(TIMESTAMP_STR.length());
+        maxSizeList.add(resultSetMetaData.getColumnLabel(i+1).length());
+      }
     }
     int j = 0;
     if (cursorBeforeFirst) {
       isReachEnd = !resultSet.next();
       cursorBeforeFirst = false;
     }
-    while (j < maxPrintRowCount && !isReachEnd) {
-      for (int i = 1; i <= columnCount; i++) {
-        String tmp;
-        if (printTimestamp && i == 1) {
-          tmp = formatDatetime(resultSet.getLong(TIMESTAMP_STR), zoneId);
-        } else {
-          tmp = resultSet.getString(i);
-        }
-        if (tmp == null) {
-          tmp = NULL;
+    if(resultSet instanceof IoTDBQueryResultSet) {
+      boolean printTimestamp = !((IoTDBQueryResultSet) resultSet).isIgnoreTimeStamp();
+      while (j < maxPrintRowCount && !isReachEnd) {
+        for (int i = 1; i <= columnCount; i++) {
+          String tmp;
+          if (printTimestamp && i == 1) {
+            tmp = formatDatetime(resultSet.getLong(TIMESTAMP_STR), zoneId);
+          } else {
+            tmp = resultSet.getString(i);
+          }
+          if (tmp == null) {
+            tmp = NULL;
+          }
+          lists.get(i - 1).add(tmp);
+          if (maxSizeList.get(i - 1) < tmp.length()) {
+            maxSizeList.set(i - 1, tmp.length());
+          }
         }
-        lists.get(i - 1).add(tmp);
-        if (maxSizeList.get(i - 1) < tmp.length()) {
-          maxSizeList.set(i - 1, tmp.length());
+        j++;
+        isReachEnd = !resultSet.next();
+      }
+      return lists;
+    } else {
+      while (j < maxPrintRowCount && !isReachEnd) {
+        for (int i = 1; i <= columnCount; i++) {
+          String tmp;
+          tmp = resultSet.getString(i);
+          if (tmp == null) {
+            tmp = NULL;
+          }
+          if (i % 2 != 0 && !tmp.equals(NULL)) {
+            tmp = formatDatetime(Long.parseLong(tmp), zoneId);
+          }
+          lists.get(i - 1).add(tmp);
+          if (maxSizeList.get(i - 1) < tmp.length()) {
+            maxSizeList.set(i - 1, tmp.length());
+          }
         }
+        j++;
+        isReachEnd = !resultSet.next();
       }
-      j++;
-      isReachEnd = !resultSet.next();
+      return lists;
     }
-    return lists;
   }
 
   private static void output(List<List<String>> lists, List<Integer> maxSizeList) {
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 34a1f42..44ad14d 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -551,7 +551,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
       // create and cache dataset
       QueryDataSet newDataSet = createQueryDataSet(queryId, plan);
-      if (plan instanceof QueryPlan && !((QueryPlan) plan).isAlignByTime()) {
+      if (plan instanceof QueryPlan && !((QueryPlan) plan).isAlignByTime() && newDataSet instanceof NonAlignEngineDataSet) {
         TSQueryNonAlignDataSet result = fillRpcNonAlignReturnData(fetchSize, newDataSet, username);
         resp.setNonAlignQueryDataSet(result);
       } else {