shizy818 commented on code in PR #14616:
URL: https://github.com/apache/iotdb/pull/14616#discussion_r1912628523


##########
iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template:
##########
@@ -1142,6 +1142,13 @@ unseq_memtable_flush_check_interval_in_ms=30000
 # effectiveMode: restart
 tvlist_sort_algorithm=TIM
 
+# When point number in the working TVList exceeds this, it is sorted and 
handover in writable memtable
+# default 0 means it does not handover working tvlist
+# effectiveMode: restart

Review Comment:
   Done



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/MergeSortAlignedTVListIterator.java:
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.utils.datastructure;
+
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.read.TimeValuePair;
+import org.apache.tsfile.read.reader.IPointReader;
+import org.apache.tsfile.utils.BitMap;
+import org.apache.tsfile.utils.TsPrimitiveType;
+
+import java.io.IOException;
+import java.util.List;
+
+public class MergeSortAlignedTVListIterator implements IPointReader {
+  private final AlignedTVList.AlignedTVListIterator[] alignedTvListIterators;
+  private final int columnNum;
+
+  private boolean probeNext = false;
+  private boolean hasNext = false;
+
+  private final int[] alignedTvListOffsets;
+
+  // Remember the selected columns for prepareNext
+  // column index -> [selectedTVList, selectedIndex]
+  private final int[][] columnAccessInfo;
+
+  private long time;
+  private final BitMap bitMap;
+
+  public MergeSortAlignedTVListIterator(
+      List<AlignedTVList> alignedTvLists,
+      List<TSDataType> tsDataTypes,
+      List<Integer> columnIndexList,
+      Integer floatPrecision,
+      List<TSEncoding> encodingList,
+      boolean ignoreAllNullRows) {
+    this.alignedTvListIterators = new 
AlignedTVList.AlignedTVListIterator[alignedTvLists.size()];
+    for (int i = 0; i < alignedTvLists.size(); i++) {
+      alignedTvListIterators[i] =
+          alignedTvLists
+              .get(i)
+              .iterator(
+                  tsDataTypes, columnIndexList, ignoreAllNullRows, 
floatPrecision, encodingList);
+    }
+    this.alignedTvListOffsets = new int[alignedTvLists.size()];
+    this.columnNum = tsDataTypes.size();
+    this.columnAccessInfo = new int[columnNum][];
+    for (int i = 0; i < columnAccessInfo.length; i++) {
+      columnAccessInfo[i] = new int[2];
+    }
+    this.bitMap = new BitMap(columnNum);
+  }
+
+  public MergeSortAlignedTVListIterator(
+      AlignedTVList.AlignedTVListIterator[] alignedTvListIterators, int 
columnNum) {
+    this.alignedTvListIterators =
+        new AlignedTVList.AlignedTVListIterator[alignedTvListIterators.length];
+    for (int i = 0; i < alignedTvListIterators.length; i++) {
+      this.alignedTvListIterators[i] = alignedTvListIterators[i].clone();
+    }
+    this.alignedTvListOffsets = new int[alignedTvListIterators.length];
+    this.columnNum = columnNum;
+    this.columnAccessInfo = new int[columnNum][];
+    for (int i = 0; i < columnAccessInfo.length; i++) {
+      columnAccessInfo[i] = new int[2];
+    }
+    this.bitMap = new BitMap(columnNum);
+  }
+
+  private void prepareNextRow() {
+    time = Long.MAX_VALUE;
+    for (int i = 0; i < alignedTvListIterators.length; i++) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to