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

haonan 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 4d7362659d6 Fixed insertTablet http api lost data event return 
SUCCESS_STATUS (#12387)
4d7362659d6 is described below

commit 4d7362659d6ad5be90cd7fee6033c134496af507
Author: CloudWise-Lukemiao <[email protected]>
AuthorDate: Wed Apr 24 17:18:37 2024 +0800

    Fixed insertTablet http api lost data event return SUCCESS_STATUS (#12387)
    
    Co-authored-by: luke.miao <[email protected]>
---
 .../protocol/rest/utils/InsertTabletSortDataUtils.java   | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
index fb1db7d4ddf..d69e89c0c99 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/utils/InsertTabletSortDataUtils.java
@@ -19,6 +19,7 @@ package org.apache.iotdb.db.protocol.rest.utils;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -33,17 +34,12 @@ public class InsertTabletSortDataUtils {
   }
 
   public static int[] sortTimeStampList(List<Long> list) {
-    int n = list.size();
-    long[] arr = new long[n];
-    for (int i = 0; i < n; i++) {
-      arr[i] = list.get(i);
+    List<Integer> indexes = new ArrayList<>();
+    for (int i = 0; i < list.size(); i++) {
+      indexes.add(i);
     }
-    Arrays.sort(arr);
-    int[] indices = new int[n];
-    for (int i = 0; i < n; i++) {
-      indices[i] = list.indexOf(arr[i]);
-    }
-    return indices;
+    indexes.sort(Comparator.comparing(list::get));
+    return indexes.stream().mapToInt(Integer::intValue).toArray();
   }
 
   public static <T> List<List<T>> sortList(List<List<T>> values, int[] index, 
int num) {

Reply via email to