HeimingZ commented on code in PR #7290:
URL: https://github.com/apache/iotdb/pull/7290#discussion_r969217906
##########
server/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java:
##########
@@ -70,17 +70,17 @@ public TVList() {
public static TVList newList(TSDataType dataType) {
switch (dataType) {
case TEXT:
- return new TimBinaryTVList();
+ return BinaryTVList.newList();
case FLOAT:
- return new TimFloatTVList();
+ return FloatTVList.newList();
case INT32:
- return new TimIntTVList();
+ return IntTVList.newList();
case INT64:
- return new TimLongTVList();
+ return LongTVList.newList();
case DOUBLE:
- return new TimDoubleTVList();
+ return DoubleTVList.newList();
case BOOLEAN:
- return new TimBooleanTVList();
+ return BooleanTVList.newList();
default:
break;
}
Review Comment:
Modify deserialize method like this.
##########
server/src/main/java/org/apache/iotdb/db/utils/datastructure/TimAlignedTVList.java:
##########
@@ -73,39 +73,6 @@ public TVList getTvListByColumnIndex(List<Integer>
columnIndex, List<TSDataType>
return alignedTvList;
}
- @Override
- public AlignedTVList clone() {
Review Comment:
Move deserialize method to AlignedTVList.
##########
server/src/main/java/org/apache/iotdb/db/utils/datastructure/BinaryTVList.java:
##########
@@ -46,6 +49,42 @@ public abstract class BinaryTVList extends TVList {
values = new ArrayList<>();
}
+ public static BinaryTVList newList() {
+ if (TVLIST_SORT_ALGORITHM == 1) {
+ return new QuickBinaryTVList();
+ }
+ return new TimBinaryTVList();
+ }
+
+ public static BinaryTVList deserialize(DataInputStream stream) throws
IOException {
+ BinaryTVList tvList = BinaryTVList.newList();
+ int rowCount = stream.readInt();
+ long[] times = new long[rowCount];
+ Binary[] values = new Binary[rowCount];
+ for (int rowIdx = 0; rowIdx < rowCount; ++rowIdx) {
+ times[rowIdx] = stream.readLong();
+ values[rowIdx] = ReadWriteIOUtils.readBinary(stream);
+ }
+ tvList.putBinaries(times, values, null, 0, rowCount);
+ return tvList;
+ }
Review Comment:
If user uses tim sort to serialize and uses quick sort to deserialize, this
deserialization method will throw an exception. We should serialize sort type
and choose different implementations when deserializing.
##########
server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java:
##########
@@ -76,11 +77,44 @@ public abstract class AlignedTVList extends TVList {
}
public static AlignedTVList newAlignedList(List<TSDataType> dataTypes) {
+ if (TVLIST_SORT_ALGORITHM == 1) {
+ return new QuickAlignedTVList(dataTypes);
+ }
return new TimAlignedTVList(dataTypes);
}
Review Comment:
Field dataTypes seems useless when initialization.
##########
server/src/assembly/resources/conf/iotdb-datanode.properties:
##########
@@ -370,6 +370,10 @@ timestamp_precision=ms
# Datatype: long
# unseq_memtable_flush_check_interval_in_ms=600000
+# The sort algorithms used in the memtable's TVList
+# 0: default tim sort, 1: quick, 2: backward
+tvList_sort_algorithm=0
Review Comment:
It’s better to use enumeration here, you can refer to compaction_priority.
--
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]