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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f02230ef [core] Shade roaringbitmap dependency into paimon-common 
(#3100)
6f02230ef is described below

commit 6f02230ef464238ef58e8811d094270dfb1a6762
Author: Zouxxyy <[email protected]>
AuthorDate: Wed Mar 27 13:29:09 2024 +0800

    [core] Shade roaringbitmap dependency into paimon-common (#3100)
---
 paimon-common/pom.xml                              | 11 ++++
 .../org/apache/paimon/utils/RoaringBitmap32.java   | 62 ++++++++++++++++++++++
 paimon-common/src/main/resources/META-INF/NOTICE   |  3 ++
 paimon-core/pom.xml                                |  7 ---
 .../deletionvectors/BitmapDeletionVector.java      | 17 +++---
 5 files changed, 84 insertions(+), 16 deletions(-)

diff --git a/paimon-common/pom.xml b/paimon-common/pom.xml
index 22d51c924..95d6458d6 100644
--- a/paimon-common/pom.xml
+++ b/paimon-common/pom.xml
@@ -135,6 +135,12 @@ under the License.
             <version>8.5.12</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.roaringbitmap</groupId>
+            <artifactId>RoaringBitmap</artifactId>
+            <version>1.0.5</version>
+        </dependency>
+
         <!-- Test -->
 
         <dependency>
@@ -266,6 +272,7 @@ under the License.
                                     <include>org.antlr:antlr4-runtime</include>
                                     <include>org.codehaus.janino:*</include>
                                     <include>it.unimi.dsi:fastutil</include>
+                                    
<include>org.roaringbitmap:RoaringBitmap</include>
                                 </includes>
                             </artifactSet>
                             <filters>
@@ -301,6 +308,10 @@ under the License.
                                     <pattern>io.airlift</pattern>
                                     
<shadedPattern>org.apache.paimon.shade.io.airlift</shadedPattern>
                                 </relocation>
+                                <relocation>
+                                    <pattern>org.roaringbitmap</pattern>
+                                    
<shadedPattern>org.apache.paimon.shade.org.roaringbitmap</shadedPattern>
+                                </relocation>
                             </relocations>
                             <minimizeJar>true</minimizeJar>
                         </configuration>
diff --git 
a/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java 
b/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java
new file mode 100644
index 000000000..31eb710ae
--- /dev/null
+++ b/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java
@@ -0,0 +1,62 @@
+/*
+ * 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.paimon.utils;
+
+import org.roaringbitmap.RoaringBitmap;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/** A compressed bitmap for 32-bit integer. */
+public class RoaringBitmap32 {
+
+    public static final int MAX_VALUE = Integer.MAX_VALUE;
+
+    private final RoaringBitmap roaringBitmap;
+
+    public RoaringBitmap32() {
+        this.roaringBitmap = new RoaringBitmap();
+    }
+
+    public void add(int x) {
+        roaringBitmap.add(x);
+    }
+
+    public boolean checkedAdd(int x) {
+        return roaringBitmap.checkedAdd(x);
+    }
+
+    public boolean contains(int x) {
+        return roaringBitmap.contains(x);
+    }
+
+    public boolean isEmpty() {
+        return roaringBitmap.isEmpty();
+    }
+
+    public void serialize(DataOutput out) throws IOException {
+        roaringBitmap.runOptimize();
+        roaringBitmap.serialize(out);
+    }
+
+    public void deserialize(DataInput in) throws IOException {
+        roaringBitmap.deserialize(in);
+    }
+}
diff --git a/paimon-common/src/main/resources/META-INF/NOTICE 
b/paimon-common/src/main/resources/META-INF/NOTICE
index 6eadf7db9..1f8f8a058 100644
--- a/paimon-common/src/main/resources/META-INF/NOTICE
+++ b/paimon-common/src/main/resources/META-INF/NOTICE
@@ -4,6 +4,9 @@ Copyright 2023-2024 The Apache Software Foundation
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).
 
+This project bundles the following dependencies under the Apache Software 
License 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
+- org.roaringbitmap:RoaringBitmap:1.0.5
+
 This project bundles the following dependencies under the BSD 3-clause license.
 You find them under licenses/LICENSE.antlr-runtime and licenses/LICENSE.janino.
 
diff --git a/paimon-core/pom.xml b/paimon-core/pom.xml
index 965f2de67..5e7339e61 100644
--- a/paimon-core/pom.xml
+++ b/paimon-core/pom.xml
@@ -33,7 +33,6 @@ under the License.
 
     <properties>
         <frocksdbjni.version>6.20.3-ververica-2.0</frocksdbjni.version>
-        <RoaringBitmap.version>1.0.1</RoaringBitmap.version>
     </properties>
 
     <dependencies>
@@ -64,12 +63,6 @@ under the License.
             <scope>provided</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.roaringbitmap</groupId>
-            <artifactId>RoaringBitmap</artifactId>
-            <version>${RoaringBitmap.version}</version>
-        </dependency>
-
         <!-- test dependencies -->
 
         <dependency>
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/deletionvectors/BitmapDeletionVector.java
 
b/paimon-core/src/main/java/org/apache/paimon/deletionvectors/BitmapDeletionVector.java
index 9ef2182e1..d15c0d210 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/deletionvectors/BitmapDeletionVector.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/deletionvectors/BitmapDeletionVector.java
@@ -18,7 +18,7 @@
 
 package org.apache.paimon.deletionvectors;
 
-import org.roaringbitmap.RoaringBitmap;
+import org.apache.paimon.utils.RoaringBitmap32;
 
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
@@ -26,20 +26,20 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 /**
- * A {@link DeletionVector} based on {@link RoaringBitmap}, it only supports 
files with row count
- * not exceeding {@link Integer#MAX_VALUE}.
+ * A {@link DeletionVector} based on {@link RoaringBitmap32}, it only supports 
files with row count
+ * not exceeding {@link RoaringBitmap32#MAX_VALUE}.
  */
 public class BitmapDeletionVector implements DeletionVector {
 
     public static final int MAGIC_NUMBER = 1581511376;
 
-    private final RoaringBitmap roaringBitmap;
+    private final RoaringBitmap32 roaringBitmap;
 
     BitmapDeletionVector() {
-        roaringBitmap = new RoaringBitmap();
+        roaringBitmap = new RoaringBitmap32();
     }
 
-    private BitmapDeletionVector(RoaringBitmap roaringBitmap) {
+    private BitmapDeletionVector(RoaringBitmap32 roaringBitmap) {
         this.roaringBitmap = roaringBitmap;
     }
 
@@ -71,7 +71,6 @@ public class BitmapDeletionVector implements DeletionVector {
         try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
                 DataOutputStream dos = new DataOutputStream(bos)) {
             dos.writeInt(MAGIC_NUMBER);
-            roaringBitmap.runOptimize();
             roaringBitmap.serialize(dos);
             return bos.toByteArray();
         } catch (Exception e) {
@@ -80,13 +79,13 @@ public class BitmapDeletionVector implements DeletionVector 
{
     }
 
     public static DeletionVector deserializeFromDataInput(DataInput bis) 
throws IOException {
-        RoaringBitmap roaringBitmap = new RoaringBitmap();
+        RoaringBitmap32 roaringBitmap = new RoaringBitmap32();
         roaringBitmap.deserialize(bis);
         return new BitmapDeletionVector(roaringBitmap);
     }
 
     private void checkPosition(long position) {
-        if (position > Integer.MAX_VALUE) {
+        if (position > RoaringBitmap32.MAX_VALUE) {
             throw new IllegalArgumentException(
                     "The file has too many rows, RoaringBitmap32 only supports 
files with row count not exceeding 2147483647.");
         }

Reply via email to