wangbo commented on a change in pull request #3090: (#3088) Support Java 
version 64 bits Integers for BITMAP type
URL: https://github.com/apache/incubator-doris/pull/3090#discussion_r396903378
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/load/loadv2/BitmapValue.java
 ##########
 @@ -0,0 +1,374 @@
+// 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.doris.load.loadv2;
+
+import org.roaringbitmap.Util;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ *
+ *  doris's own java version bitmap
+ *  try to keep compatibility with doris be's bitmap_value.h,but still has 
some difference from bitmap_value.h
+ *  major difference from be:
+ *      1. java bitmap support integer range [0, Long.MAX],while be's bitmap 
support range [0, Long.MAX * 2]
+ *          Now Long.MAX_VALUE is enough for doris's spark load and support 
unsigned integer in java need to pay more
+ *      2. getSizeInBytes method is different from fe to be, details 
description see method comment
+ */
+public class BitmapValue {
+
+    public static final int EMPTY = 0;
+    public static final int SINGLE32 = 1;
+    public static final int BITMAP32 = 2;
+    public static final int SINGLE64 = 3;
+    public static final int BITMAP64 = 4;
+
+    public static final int SINGLE_VALUE = 1;
+    public static final int BITMAP_VALUE = 2;
+
+    private int bitmapType;
+    private long singleValue;
+    private Roaring64Map bitmap;
+
+    public BitmapValue() {
+        bitmapType = EMPTY;
+    }
+
+    public void add(int value) {
+        add(Util.toUnsignedLong(value));
+    }
+
+    public void add(long value) {
+        switch (bitmapType) {
+            case EMPTY:
+                singleValue = value;
+                bitmapType = SINGLE_VALUE;
+                break;
+            case SINGLE_VALUE:
+                if (this.singleValue != value) {
 
 Review comment:
   If user input two identical value in a row, the check can avoid the 
generation of a bitmap.
   And ```change singleValue to invalid``` is not a necessary operator, because 
```single value``` must comes from ```empty```,even after BitmapValue clear();

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to