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

hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 74cbf19  [ISSUE-2479] Remove redundant logic in 
session.genTSInsertRecordsOfOneDeviceReq() (#2480)
74cbf19 is described below

commit 74cbf1909dd76040e7eb41fe74161bee991890f9
Author: Xiangwei Wei <[email protected]>
AuthorDate: Wed Jan 13 10:52:48 2021 +0800

    [ISSUE-2479] Remove redundant logic in 
session.genTSInsertRecordsOfOneDeviceReq() (#2480)
---
 session/src/main/java/org/apache/iotdb/session/Session.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/session/src/main/java/org/apache/iotdb/session/Session.java 
b/session/src/main/java/org/apache/iotdb/session/Session.java
index dff07d9..a27dd31 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -640,19 +640,17 @@ public class Session {
     } else {
       //sort
       Integer[] index = new Integer[times.size()];
-      Integer[] index2 = new Integer[times.size()];
       for (int i = 0; i < times.size(); i++) {
-        index2[i] = index[i] = i;
+        index[i] = i;
       }
       Arrays.sort(index, Comparator.comparingLong(times::get));
-      Arrays.sort(index2, Comparator.comparingInt(x -> index[x]));
       times.sort(Long::compareTo);
       //sort measurementList
-      measurementsList = sortList(measurementsList, index2);
+      measurementsList = sortList(measurementsList, index);
       //sort typesList
-      typesList = sortList(typesList, index2);
+      typesList = sortList(typesList, index);
       //sort values
-      valuesList = sortList(valuesList, index2);
+      valuesList = sortList(valuesList, index);
     }
 
     TSInsertRecordsOfOneDeviceReq request = new 
TSInsertRecordsOfOneDeviceReq();
@@ -668,7 +666,7 @@ public class Session {
   private List sortList(List source, Integer[] index) {
     Object[] result = new Object[source.size()];
     for (int i = 0; i < index.length; i++) {
-      result[index[i]] = source.get(i);
+      result[i] = source.get(index[i]);
     }
     return Arrays.asList(result);
   }

Reply via email to