imay commented on a change in pull request #1610: Add bitmap agg type and udaf
URL: https://github.com/apache/incubator-doris/pull/1610#discussion_r316943782
 
 

 ##########
 File path: be/src/util/bitmap.h
 ##########
 @@ -248,6 +250,144 @@ class Bitmap {
   static const int64_t BIT_INDEX_MASK = 63;
 };
 
+enum BitmapDataType {
+    EMPTY = 0,
+    INT32,
+    BITMAP
+};
+
+// the wrapper class for RoaringBitmap
+// todo(kks): improve for low cardinality set
+class RoaringBitmap {
+public:
+    RoaringBitmap() {
+        _type = EMPTY;
+    }
+
+    explicit RoaringBitmap(int32_t value) {
+        _int_value = value;
+        _type = INT32;
+    }
+
+    explicit RoaringBitmap(const char* src) {
+        _type = (BitmapDataType)src[0];
+        switch (_type) {
+            case EMPTY:
+                break;
+            case INT32:
+                _int_value = *reinterpret_cast<const int32_t*>(src + 1);
+                break;
+            case BITMAP:
+                _roaring = Roaring::read(src + 1);
+        }
+    }
+
+    void update(int32_t x) {
+        if (_type == INT32) {
+            _roaring.add(_int_value);
+        }
+        _roaring.add(x);
+        _type = BITMAP;
+    }
+
+    // need change the type:
+    // EMPTY -> INT
+    // EMPTY -> BITMAP
+    // INT   -> BITMAP
+    void merge(RoaringBitmap& bitmap) {
 
 Review comment:
   ```suggestion
       void merge(const RoaringBitmap& bitmap) {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to