You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/04/07 09:19:02 UTC
[iotdb] branch sortBitMap created (now 0bc88c9)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a change to branch sortBitMap
in repository https://gitbox.apache.org/repos/asf/iotdb.git.
at 0bc88c9 [To Vector] support sort tablet with bitmaps
This branch includes the following new commits:
new 0bc88c9 [To Vector] support sort tablet with bitmaps
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.
[iotdb] 01/01: [To Vector] support sort tablet with bitmaps
Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch sortBitMap
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0bc88c99f3554bb04a11195032809c7a35d77e7f
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Apr 7 17:18:23 2021 +0800
[To Vector] support sort tablet with bitmaps
---
.../main/java/org/apache/iotdb/session/Session.java | 21 +++++++++++++++++++++
.../java/org/apache/iotdb/tsfile/utils/BitMap.java | 16 ++++++++--------
2 files changed, 29 insertions(+), 8 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 8358fb8..d059b53 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -43,6 +43,7 @@ import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.utils.BitMap;
import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.apache.iotdb.tsfile.write.record.Tablet;
import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
@@ -1538,6 +1539,9 @@ public class Session {
for (int j = 0; j < measurementSize; j++) {
tablet.values[columnIndex] =
sortList(tablet.values[columnIndex], schema.getValueTSDataTypeList().get(i), index);
+ if (tablet.bitMaps != null && tablet.bitMaps[columnIndex] != null) {
+ tablet.bitMaps[columnIndex] = sortBitMap(tablet.bitMaps[columnIndex], index);
+ }
columnIndex++;
}
}
@@ -1601,6 +1605,23 @@ public class Session {
}
}
+ /**
+ * sort BitMap by index
+ *
+ * @param bitMap bitMap to be sort
+ * @param index index
+ * @return sorted BitMap
+ */
+ private BitMap sortBitMap(BitMap bitMap, Integer[] index) {
+ BitMap sortedBitMap = new BitMap(bitMap.getSize());
+ for (int i = 0; i < index.length; i++) {
+ if (bitMap.get(index[i])) {
+ sortedBitMap.mark(i);
+ }
+ }
+ return sortedBitMap;
+ }
+
public void setDeviceTemplate(String templateName, String prefixPath)
throws IoTDBConnectionException, StatementExecutionException {
TSSetDeviceTemplateReq request = getTSSetDeviceTemplateReq(templateName, prefixPath);
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BitMap.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BitMap.java
index ac207ec..bffbd4e 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BitMap.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/BitMap.java
@@ -24,14 +24,14 @@ public class BitMap {
private static final byte[] BIT_UTIL = new byte[] {1, 2, 4, 8, 16, 32, 64, -128};
private static final byte[] UNMARK_BIT_UTIL =
new byte[] {
- (byte) 0XFE,
- (byte) 0XFD,
- (byte) 0XFB,
- (byte) 0XF7,
- (byte) 0XEF,
- (byte) 0XDF,
- (byte) 0XBF,
- (byte) 0X7F
+ (byte) 0XFE, // 11111110
+ (byte) 0XFD, // 11111101
+ (byte) 0XFB, // 11111011
+ (byte) 0XF7, // 11110111
+ (byte) 0XEF, // 11101111
+ (byte) 0XDF, // 11011111
+ (byte) 0XBF, // 10111111
+ (byte) 0X7F // 01111111
};
private byte[] bits;