wuchong commented on code in PR #2390:
URL: https://github.com/apache/fluss/pull/2390#discussion_r2702183227
##########
fluss-common/pom.xml:
##########
@@ -62,6 +62,12 @@
<artifactId>fluss-shaded-arrow</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.roaringbitmap</groupId>
+ <artifactId>RoaringBitmap</artifactId>
+ <version>${roaringbitmap.version}</version>
Review Comment:
I noticed that the RoaringBitmap dependency is currently only used in
`fluss-server`. To minimize downstream impact, could we move it from
`fluss-common` into `fluss-server`?
Placing it in `fluss-common` forces all clients and connectors to inherit
this dependency, which is highly likely to cause version conflicts—Paimon uses
RoaringBitmap 1.2.1, while Flink uses 1.3.0, for example.
On the other hand, we may eventually need RoaringBitmap in fluss-common once
we support local aggregation (e.g., in SQL or client-side pre-aggregation). To
prepare for that while avoiding conflicts, I’ve opened an issue in the
`fluss-shaded` repository to shade the `org.roaringbitmap` package:
https://github.com/apache/fluss-shaded/issues/4
For now, scoping the dependency to `fluss-server` seems like the safest
approach.
##########
fluss-common/src/main/java/org/apache/fluss/utils/RoaringBitmapUtils.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.fluss.utils;
+
+import org.roaringbitmap.RoaringBitmap;
+import org.roaringbitmap.longlong.Roaring64Bitmap;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/** Utility methods for serializing roaring bitmaps. */
+public final class RoaringBitmapUtils {
+
+ private RoaringBitmapUtils() {
+ // Utility class, no instantiation
+ }
+
+ public static byte[] serializeRoaringBitmap32(RoaringBitmap bitmap) throws
IOException {
+ bitmap.runOptimize();
+ ByteBuffer buffer =
ByteBuffer.allocate(bitmap.serializedSizeInBytes());
+ bitmap.serialize(buffer);
+ return buffer.array();
+ }
+
+ public static void deserializeRoaringBitmap32(RoaringBitmap bitmap, byte[]
bytes)
+ throws IOException {
+ bitmap.deserialize(ByteBuffer.wrap(bytes));
+ }
+
+ public static byte[] serializeRoaringBitmap64(Roaring64Bitmap bitmap)
throws IOException {
+ bitmap.runOptimize();
+ try (ByteArrayOutputStream output = new ByteArrayOutputStream();
+ DataOutputStream dataOutput = new DataOutputStream(output)) {
+ bitmap.serialize(dataOutput);
Review Comment:
I’m curious about the choice to use `DataOutputStream` for serializing
rbm64, whereas `serializeRoaringBitmap32` uses ByteBuffer.
Is there a specific reason for this difference in serialization strategy?
The Javadoc of RoaringBitmap#serialize(java.nio.ByteBuffer) says:
> Serialize this bitmap to a ByteBuffer. This is the preferred method to
serialize to a byte array (byte[]) or to a String
##########
pom.xml:
##########
@@ -91,6 +91,7 @@
<arrow.version>15.0.0</arrow.version>
<paimon.version>1.3.1</paimon.version>
<iceberg.version>1.10.0</iceberg.version>
+ <roaringbitmap.version>1.2.1</roaringbitmap.version>
Review Comment:
It seems the latest stable version is 1.3.0, and both Iceberg[1], Flink [2]
use that version. Should we upgrade version to that?
[1]
https://github.com/apache/iceberg/blob/e93eaab330581999d8fd8e4e6f5f885446cf28c3/gradle/libs.versions.toml#L86
[2]
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=399278679#FLIP556:IntroduceBITMAPDataType-InternalImplementationDetails
##########
git-issue-roaringbitmap-agg.md:
##########
@@ -0,0 +1,15 @@
+Title: Add RoaringBitmap aggregation support to Fluss merge engine
Review Comment:
remove this file?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]