You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "Prajwal-banakar (via GitHub)" <gi...@apache.org> on 2026/05/14 16:07:17 UTC

[PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Prajwal-banakar opened a new pull request, #3319:
URL: https://github.com/apache/fluss/pull/3319

   
   
   <!--
   *Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
   
     - Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
   
     - **Generative AI disclosure:** Indicate whether generative AI tools were used in authoring this PR. If yes, specify the tool below.
       - [ ] No generative AI tools used
       - [ ] Yes (please specify the tool below)
   
   **(The sections below can be removed for hotfixes or typos)**
   -->
   
   <!--
   Generated-by: [Tool Name and Version] following [the guidelines](https://github.com/apache/fluss/blob/main/AGENTS.md)
   -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   
   Linked issue: close #3289
   
   <!-- What is the purpose of the change -->
   
   This PR adds the foundational infrastructure for FIP-37 RoaringBitmap SQL function implementation. It provides the serialization utilities, custom Flink type serializer, and base aggregate function class that will be used by the bitmap SQL functions (`rb_build_agg`, `rb_or_agg`, `rb_and_agg`, etc.) in subsequent PRs.
   
   ### Brief change log
   
   <!-- Please describe the changes made in this pull request and explain how they address the issue -->
   Added the following infrastructure files in `fluss-flink/fluss-flink-common`:
   
   - **BitmapUtils.java**: Utility methods for serializing/deserializing `RoaringBitmap` using the ByteBuffer-based approach, which matches the server-side `RoaringBitmapUtils.serializeRoaringBitmap32` format used by `FieldRoaringBitmap32Agg` for wire compatibility
   - **RoaringBitmapSerializer.java**: Custom Flink `TypeSerializer` for `RoaringBitmap` accumulators to ensure correct checkpoint/savepoint behavior. Without this, Flink falls back to Kryo which is sensitive to internal class layout changes across RoaringBitmap library versions
   - **RoaringBitmapTypeInfo.java**: `TypeInformation` wrapper that provides the custom serializer to Flink's type system
   - **AbstractRbAggFunction.java**: Base class for bitmap aggregate UDFs with `@FunctionHint(accumulator = @DataTypeHint(value = "RAW", bridgedTo = RoaringBitmap.class))` annotation. This tells Flink's Table planner to skip reflection-based POJO field extraction on RoaringBitmap and use the custom `TypeInformation` instead
   - **BitmapUtilsTest.java**: Unit tests covering null handling, empty bitmap, known values round-trip, large cardinality (100K elements), and server serialization compatibility
   - **pom.xml**: Added `RoaringBitmap` dependency (version 1.3.0 from root pom)
   
   The aggregate functions (`rb_build_agg`, `rb_or_agg`, `rb_and_agg`) and catalog registration will follow in subsequent PRs linked to this issue.
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   Unit tests added and passing:
   - `BitmapUtilsTest.testNullInputToBytes()` - null handling
   - `BitmapUtilsTest.testNullInputFromBytes()` - null handling  
   - `BitmapUtilsTest.testEmptyBitmapRoundTrip()` - empty bitmap serialization
   - `BitmapUtilsTest.testKnownValuesRoundTrip()` - correctness with known values
   - `BitmapUtilsTest.testLargeCardinality()` - performance with 100K elements
   - `BitmapUtilsTest.testFormatCompatibleWithServerSerialization()` - wire compatibility
   
   All tests pass: `Tests run: 6, Failures: 0, Errors: 0, Skipped: 0`
   
   Verified with:
   - `./mvnw spotless:apply -pl fluss-flink/fluss-flink-common` - BUILD SUCCESS
   - `./mvnw test -pl fluss-flink/fluss-flink-common -Dtest=BitmapUtilsTest` - BUILD SUCCESS
   - `./mvnw clean install -pl fluss-flink/fluss-flink-common -DskipTests` - BUILD SUCCESS
   - ` ./mvnw clean package -DskipTests` (full project build) - BUILD SUCCESS
   - Checkstyle: 0 violations
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   This change does not affect any public API or storage format. It adds internal infrastructure utilities that will be used by future bitmap SQL functions.
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   This change does not introduce new user-facing features yet. The bitmap SQL functions (`rb_build_agg`, `rb_or_agg`, `rb_and_agg`) and their documentation will be added in follow-up PRs.
   


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on code in PR #3319:
URL: https://github.com/apache/fluss/pull/3319#discussion_r3260497838


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/RoaringBitmapSerializer.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeutils.SimpleTypeSerializerSnapshot;
+import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
+import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.roaringbitmap.RoaringBitmap;
+
+import java.io.IOException;
+
+/**
+ * Flink {@link org.apache.flink.api.common.typeutils.TypeSerializer} for {@link RoaringBitmap}.
+ *
+ * <p>Used as the accumulator serializer for bitmap aggregate functions to ensure correct
+ * checkpoint/savepoint behavior. Without a custom serializer, Flink falls back to Kryo which is
+ * sensitive to internal class layout changes across RoaringBitmap library versions.
+ */
+public final class RoaringBitmapSerializer extends TypeSerializerSingleton<RoaringBitmap> {
+
+    public static final RoaringBitmapSerializer INSTANCE = new RoaringBitmapSerializer();
+
+    private static final long serialVersionUID = 1L;
+
+    private RoaringBitmapSerializer() {}
+
+    @Override
+    public boolean isImmutableType() {
+        return false;
+    }
+
+    @Override
+    public RoaringBitmap createInstance() {
+        return new RoaringBitmap();
+    }
+
+    @Override
+    public RoaringBitmap copy(RoaringBitmap from) {
+        return from.clone();
+    }
+
+    @Override
+    public RoaringBitmap copy(RoaringBitmap from, RoaringBitmap reuse) {
+        return from.clone();
+    }
+
+    @Override
+    public int getLength() {
+        return -1;
+    }
+
+    @Override
+    public void serialize(RoaringBitmap record, DataOutputView target) throws IOException {

Review Comment:
   Fixed, removed the redundant runOptimize() call from serialize(); BitmapUtils.toBytes() handles it.



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/RoaringBitmapTypeInfo.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.roaringbitmap.RoaringBitmap;
+
+import java.util.Objects;
+
+/**
+ * {@link TypeInformation} for {@link RoaringBitmap}.
+ *
+ * <p>Provides the custom {@link RoaringBitmapSerializer} to Flink's type system, ensuring correct
+ * checkpoint and savepoint behavior for bitmap aggregate function accumulators.
+ */
+public final class RoaringBitmapTypeInfo extends TypeInformation<RoaringBitmap> {
+
+    public static final RoaringBitmapTypeInfo INSTANCE = new RoaringBitmapTypeInfo();
+
+    private static final long serialVersionUID = 1L;
+
+    private RoaringBitmapTypeInfo() {}
+
+    @Override
+    public boolean isBasicType() {
+        return false;
+    }
+
+    @Override
+    public boolean isTupleType() {
+        return false;
+    }
+
+    @Override
+    public int getArity() {
+        return 1;
+    }
+
+    @Override
+    public int getTotalFields() {
+        return 1;
+    }
+
+    @Override
+    public Class<RoaringBitmap> getTypeClass() {
+        return RoaringBitmap.class;
+    }
+
+    @Override
+    public boolean isKeyType() {
+        return false;
+    }
+
+    @Override
+    public TypeSerializer<RoaringBitmap> createSerializer(ExecutionConfig config) {
+        return RoaringBitmapSerializer.INSTANCE;
+    }
+
+    @Override
+    public String toString() {
+        return "RoaringBitmapTypeInfo";
+    }
+
+    @Override
+    public boolean equals(Object obj) {

Review Comment:
   Fixed equals to delegate through canEqual. Added @ThreadSafe to both classes.



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on code in PR #3319:
URL: https://github.com/apache/fluss/pull/3319#discussion_r3256913771


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/AbstractRbAggFunction.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.annotation.DataTypeHint;
+import org.apache.flink.table.annotation.FunctionHint;
+import org.apache.flink.table.functions.AggregateFunction;
+import org.roaringbitmap.RoaringBitmap;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+
+/**
+ * Shared base for bitmap aggregate UDFs that use {@link RoaringBitmap} as the accumulator.
+ *
+ * <p>The {@code @FunctionHint} annotation with {@code accumulator = @DataTypeHint("RAW")} tells
+ * Flink's Table planner to skip reflection-based POJO extraction and instead use the {@link
+ * TypeInformation} returned by {@link #getAccumulatorType()}, which provides the custom {@link
+ * RoaringBitmapSerializer}. Without this annotation, Flink attempts POJO field extraction on
+ * RoaringBitmap and fails.
+ */
+@FunctionHint(accumulator = @DataTypeHint(value = "RAW", bridgedTo = RoaringBitmap.class))
+abstract class AbstractRbAggFunction extends AggregateFunction<byte[], RoaringBitmap> {
+
+    @Override
+    public RoaringBitmap createAccumulator() {
+        return new RoaringBitmap();
+    }
+
+    /** Merges multiple accumulators — required for session window aggregation. */

Review Comment:
   "required for session window aggregation" is misleading.
   The  merge operation is required for any two-phase / batch / merge-capable aggregation in the Flink Table API, not specifically session windows



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/AbstractRbAggFunction.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.annotation.DataTypeHint;
+import org.apache.flink.table.annotation.FunctionHint;
+import org.apache.flink.table.functions.AggregateFunction;
+import org.roaringbitmap.RoaringBitmap;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+
+/**
+ * Shared base for bitmap aggregate UDFs that use {@link RoaringBitmap} as the accumulator.
+ *
+ * <p>The {@code @FunctionHint} annotation with {@code accumulator = @DataTypeHint("RAW")} tells
+ * Flink's Table planner to skip reflection-based POJO extraction and instead use the {@link
+ * TypeInformation} returned by {@link #getAccumulatorType()}, which provides the custom {@link
+ * RoaringBitmapSerializer}. Without this annotation, Flink attempts POJO field extraction on
+ * RoaringBitmap and fails.
+ */
+@FunctionHint(accumulator = @DataTypeHint(value = "RAW", bridgedTo = RoaringBitmap.class))
+abstract class AbstractRbAggFunction extends AggregateFunction<byte[], RoaringBitmap> {
+
+    @Override
+    public RoaringBitmap createAccumulator() {
+        return new RoaringBitmap();
+    }
+
+    /** Merges multiple accumulators — required for session window aggregation. */
+    public void merge(RoaringBitmap acc, Iterable<RoaringBitmap> it) {
+        for (RoaringBitmap other : it) {
+            if (other != null) {
+                acc.or(other);
+            }
+        }
+    }
+
+    public void resetAccumulator(RoaringBitmap acc) {
+        acc.clear();
+    }
+
+    @Override
+    @Nullable
+    public byte[] getValue(RoaringBitmap acc) {
+        if (acc == null || acc.isEmpty()) {
+            return null;
+        }
+        try {
+            return BitmapUtils.toBytes(acc);
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to serialize bitmap accumulator.", e);

Review Comment:
   use `FlussRuntimeException`



##########
fluss-test-coverage/pom.xml:
##########
@@ -484,6 +484,9 @@
                                         <exclude>org.apache.fluss.flink.tiering.FlussLakeTieringEntrypoint</exclude>
                                         <exclude>org.apache.fluss.flink.tiering.FlussLakeTiering</exclude>
                                         <!-- end exclude for flink tiering service -->
+                                        <exclude>

Review Comment:
   instead of excluding can we add some test, for example for 
    merge / getValue / resetAccumulator? maybe ship with just only one concrete implementation? 
   
   without a consumer, there's no way to validate that the planner actually accepts the RAW(... bridgedTo = RoaringBitmap.class) hint together with the custom TypeInformation.
   WDYT?



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/RoaringBitmapTypeInfo.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.roaringbitmap.RoaringBitmap;
+
+import java.util.Objects;
+
+/**
+ * {@link TypeInformation} for {@link RoaringBitmap}.
+ *
+ * <p>Provides the custom {@link RoaringBitmapSerializer} to Flink's type system, ensuring correct
+ * checkpoint and savepoint behavior for bitmap aggregate function accumulators.
+ */
+public final class RoaringBitmapTypeInfo extends TypeInformation<RoaringBitmap> {
+
+    public static final RoaringBitmapTypeInfo INSTANCE = new RoaringBitmapTypeInfo();
+
+    private static final long serialVersionUID = 1L;
+
+    private RoaringBitmapTypeInfo() {}
+
+    @Override
+    public boolean isBasicType() {
+        return false;
+    }
+
+    @Override
+    public boolean isTupleType() {
+        return false;
+    }
+
+    @Override
+    public int getArity() {
+        return 1;
+    }
+
+    @Override
+    public int getTotalFields() {
+        return 1;
+    }
+
+    @Override
+    public Class<RoaringBitmap> getTypeClass() {
+        return RoaringBitmap.class;
+    }
+
+    @Override
+    public boolean isKeyType() {
+        return false;
+    }
+
+    @Override
+    public TypeSerializer<RoaringBitmap> createSerializer(ExecutionConfig config) {
+        return RoaringBitmapSerializer.INSTANCE;
+    }
+
+    @Override
+    public String toString() {
+        return "RoaringBitmapTypeInfo";
+    }
+
+    @Override
+    public boolean equals(Object obj) {

Review Comment:
   equals doesn't delegate through `canEqual`, which breaks Flink's documented symmetry contract for TypeInformation subclasses. 
   
   Either: return obj instanceof RoaringBitmapTypeInfo && ((RoaringBitmapTypeInfo) obj).canEqual(this); or simplify the whole class to reference equality since the constructor is private and INSTANCE is the only instance. Also worth adding @ThreadSafe here and on RoaringBitmapSerializer



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/RoaringBitmapSerializer.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeutils.SimpleTypeSerializerSnapshot;
+import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
+import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.roaringbitmap.RoaringBitmap;
+
+import java.io.IOException;
+
+/**
+ * Flink {@link org.apache.flink.api.common.typeutils.TypeSerializer} for {@link RoaringBitmap}.
+ *
+ * <p>Used as the accumulator serializer for bitmap aggregate functions to ensure correct
+ * checkpoint/savepoint behavior. Without a custom serializer, Flink falls back to Kryo which is
+ * sensitive to internal class layout changes across RoaringBitmap library versions.
+ */
+public final class RoaringBitmapSerializer extends TypeSerializerSingleton<RoaringBitmap> {
+
+    public static final RoaringBitmapSerializer INSTANCE = new RoaringBitmapSerializer();
+
+    private static final long serialVersionUID = 1L;
+
+    private RoaringBitmapSerializer() {}
+
+    @Override
+    public boolean isImmutableType() {
+        return false;
+    }
+
+    @Override
+    public RoaringBitmap createInstance() {
+        return new RoaringBitmap();
+    }
+
+    @Override
+    public RoaringBitmap copy(RoaringBitmap from) {
+        return from.clone();
+    }
+
+    @Override
+    public RoaringBitmap copy(RoaringBitmap from, RoaringBitmap reuse) {
+        return from.clone();
+    }
+
+    @Override
+    public int getLength() {
+        return -1;
+    }
+
+    @Override
+    public void serialize(RoaringBitmap record, DataOutputView target) throws IOException {

Review Comment:
   `record.runOptimize()` is called here and then BitmapUtils.toBytes(record) also calls runOptimize().



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on PR #3319:
URL: https://github.com/apache/fluss/pull/3319#issuecomment-4540513768

   @Prajwal-banakar thank you for all the great work.. I pushed one small commit with some small changes.
   Let me know if it looks to you and i can merge once the CI passes


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on PR #3319:
URL: https://github.com/apache/fluss/pull/3319#issuecomment-4479750752

   Hi @polyzos Thanks for the review, addresses all the comments, Please take another look when you get a time!


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on PR #3319:
URL: https://github.com/apache/fluss/pull/3319#issuecomment-4465466044

   Hi @polyzos @wuchong @platinumhamburg could you please help review here? 


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on code in PR #3319:
URL: https://github.com/apache/fluss/pull/3319#discussion_r3260491303


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/AbstractRbAggFunction.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.annotation.DataTypeHint;
+import org.apache.flink.table.annotation.FunctionHint;
+import org.apache.flink.table.functions.AggregateFunction;
+import org.roaringbitmap.RoaringBitmap;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+
+/**
+ * Shared base for bitmap aggregate UDFs that use {@link RoaringBitmap} as the accumulator.
+ *
+ * <p>The {@code @FunctionHint} annotation with {@code accumulator = @DataTypeHint("RAW")} tells
+ * Flink's Table planner to skip reflection-based POJO extraction and instead use the {@link
+ * TypeInformation} returned by {@link #getAccumulatorType()}, which provides the custom {@link
+ * RoaringBitmapSerializer}. Without this annotation, Flink attempts POJO field extraction on
+ * RoaringBitmap and fails.
+ */
+@FunctionHint(accumulator = @DataTypeHint(value = "RAW", bridgedTo = RoaringBitmap.class))
+abstract class AbstractRbAggFunction extends AggregateFunction<byte[], RoaringBitmap> {
+
+    @Override
+    public RoaringBitmap createAccumulator() {
+        return new RoaringBitmap();
+    }
+
+    /** Merges multiple accumulators — required for session window aggregation. */

Review Comment:
   Updated the Javadoc



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on code in PR #3319:
URL: https://github.com/apache/fluss/pull/3319#discussion_r3260503371


##########
fluss-test-coverage/pom.xml:
##########
@@ -484,6 +484,9 @@
                                         <exclude>org.apache.fluss.flink.tiering.FlussLakeTieringEntrypoint</exclude>
                                         <exclude>org.apache.fluss.flink.tiering.FlussLakeTiering</exclude>
                                         <!-- end exclude for flink tiering service -->
+                                        <exclude>

Review Comment:
   Added a minimal concrete TestRbAggFunction in the test class and covered merge, getValue, resetAccumulator, and getAccumulatorType. Removed the jacoco exclude.



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos merged PR #3319:
URL: https://github.com/apache/fluss/pull/3319


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos commented on PR #3319:
URL: https://github.com/apache/fluss/pull/3319#issuecomment-4475221116

   @Prajwal-banakar great work so far .. I just added a few comments, as small impovements, but it's almost there  


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on code in PR #3319:
URL: https://github.com/apache/fluss/pull/3319#discussion_r3260484054


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/AbstractRbAggFunction.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.flink.functions.bitmap;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.annotation.DataTypeHint;
+import org.apache.flink.table.annotation.FunctionHint;
+import org.apache.flink.table.functions.AggregateFunction;
+import org.roaringbitmap.RoaringBitmap;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+
+/**
+ * Shared base for bitmap aggregate UDFs that use {@link RoaringBitmap} as the accumulator.
+ *
+ * <p>The {@code @FunctionHint} annotation with {@code accumulator = @DataTypeHint("RAW")} tells
+ * Flink's Table planner to skip reflection-based POJO extraction and instead use the {@link
+ * TypeInformation} returned by {@link #getAccumulatorType()}, which provides the custom {@link
+ * RoaringBitmapSerializer}. Without this annotation, Flink attempts POJO field extraction on
+ * RoaringBitmap and fails.
+ */
+@FunctionHint(accumulator = @DataTypeHint(value = "RAW", bridgedTo = RoaringBitmap.class))
+abstract class AbstractRbAggFunction extends AggregateFunction<byte[], RoaringBitmap> {
+
+    @Override
+    public RoaringBitmap createAccumulator() {
+        return new RoaringBitmap();
+    }
+
+    /** Merges multiple accumulators — required for session window aggregation. */
+    public void merge(RoaringBitmap acc, Iterable<RoaringBitmap> it) {
+        for (RoaringBitmap other : it) {
+            if (other != null) {
+                acc.or(other);
+            }
+        }
+    }
+
+    public void resetAccumulator(RoaringBitmap acc) {
+        acc.clear();
+    }
+
+    @Override
+    @Nullable
+    public byte[] getValue(RoaringBitmap acc) {
+        if (acc == null || acc.isEmpty()) {
+            return null;
+        }
+        try {
+            return BitmapUtils.toBytes(acc);
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to serialize bitmap accumulator.", e);

Review Comment:
   Done  switched to FlussRuntimeException



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FIP-37] Add bitmap infrastructure: BitmapUtils, RoaringBitmapSerializer, AbstractRbAggFunction [fluss]

Posted by "Prajwal-banakar (via GitHub)" <gi...@apache.org>.
Prajwal-banakar commented on PR #3319:
URL: https://github.com/apache/fluss/pull/3319#issuecomment-4540790356

   Hi @polyzos Thank you for the improvements! the ITCase is a much cleaner solution for validating the planner contract, and the serialize fix is cleaner too. LGTM!
   the failing CI check is in fluss-server (JVM crash: "pure virtual method called" from native RocksDB code), which is unrelated to this PR's changes in fluss-flink-common. This looks like a pre-existing runner flake


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org