You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/11/12 02:38:27 UTC

[incubator-doris] branch master updated: [SparkDpp]Add not() and xor() methods to bitmapValue (#6885)

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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 35da149  [SparkDpp]Add not() and xor() methods to bitmapValue (#6885)
35da149 is described below

commit 35da149ebe379bd593928106e84acec9b61ad6ce
Author: lihuigang <35...@users.noreply.github.com>
AuthorDate: Fri Nov 12 10:38:15 2021 +0800

    [SparkDpp]Add not() and xor() methods to bitmapValue (#6885)
    
    Add not() and xor() methods to bitmapValue
---
 .../apache/doris/load/loadv2/dpp/BitmapValue.java  | 93 ++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/BitmapValue.java b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/BitmapValue.java
index 742a68e..9e44bd5 100644
--- a/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/BitmapValue.java
+++ b/fe/spark-dpp/src/main/java/org/apache/doris/load/loadv2/dpp/BitmapValue.java
@@ -227,6 +227,99 @@ public class BitmapValue {
         }
     }
 
+    public void remove(long value){
+        switch (this.bitmapType){
+            case EMPTY:
+                break;
+            case SINGLE_VALUE:
+                if(this.singleValue == value) {
+                    clear();
+                }
+                break;
+            case BITMAP_VALUE:
+                this.bitmap.removeLong(value);
+                convertToSmallerType();
+                break;
+        }
+    }
+
+    //In-place bitwise ANDNOT (difference) operation. The current bitmap is modified
+    public void not(BitmapValue other) {
+        switch (other.bitmapType) {
+            case EMPTY:
+                break;
+            case SINGLE_VALUE:
+                remove(other.singleValue);
+                break;
+            case BITMAP_VALUE:
+                switch (this.bitmapType) {
+                    case EMPTY:
+                        break;
+                    case SINGLE_VALUE:
+                        if(other.bitmap.contains(this.singleValue)){
+                            clear();
+                        }
+                        break;
+                    case BITMAP_VALUE:
+                        this.bitmap.andNot(other.bitmap);
+                        convertToSmallerType();
+                        break;
+                }
+                break;
+        }
+    }
+
+    //In-place bitwise XOR (symmetric difference) operation. The current bitmap is modified
+    public void xor(BitmapValue other) {
+        switch (other.bitmapType) {
+            case EMPTY:
+                break;
+            case SINGLE_VALUE:
+                switch (this.bitmapType){
+                    case EMPTY:
+                        add(other.singleValue);
+                        break;
+                    case SINGLE_VALUE:
+                        if(this.singleValue != other.singleValue){
+                            add(other.singleValue);
+                        }else{
+                            clear();
+                        }
+                        break;
+                    case BITMAP_VALUE:
+                        if(!this.bitmap.contains(other.singleValue)){
+                            this.bitmap.add(other.singleValue);
+                        }else{
+                            this.bitmap.removeLong(other.singleValue);
+                            convertToSmallerType();
+                        }
+                        break;
+                }
+                break;
+            case BITMAP_VALUE:
+                switch (this.bitmapType) {
+                    case EMPTY:
+                        this.bitmap = other.bitmap;
+                        this.bitmapType = BITMAP_VALUE;
+                        break;
+                    case SINGLE_VALUE:
+                        this.bitmap = other.bitmap;
+                        this.bitmapType = BITMAP_VALUE;
+                        if(this.bitmap.contains(this.singleValue)){
+                            this.bitmap.removeLong(this.singleValue);
+                        }else{
+                            this.bitmap.add(this.bitmapType);
+                        }
+                        break;
+                    case BITMAP_VALUE:
+                        this.bitmap.xor(other.bitmap);
+                        convertToSmallerType();
+                        break;
+                }
+                break;
+        }
+    }
+
     public boolean equals(BitmapValue other) {
         boolean ret = false;
         if (this.bitmapType != other.bitmapType) {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org