polyzos commented on code in PR #3398:
URL: https://github.com/apache/fluss/pull/3398#discussion_r3361072622


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/catalog/FlinkCatalog.java:
##########
@@ -746,19 +760,24 @@ public void alterPartition(
     }
 
     @Override
-    public List<String> listFunctions(String s) throws 
DatabaseNotExistException, CatalogException {
-        return Collections.emptyList();
+    public List<String> listFunctions(String dbName)
+            throws DatabaseNotExistException, CatalogException {
+        return new ArrayList<>(BUILTIN_BITMAP_FUNCTIONS.keySet());
     }
 
     @Override
-    public CatalogFunction getFunction(ObjectPath functionPath)
-            throws FunctionNotExistException, CatalogException {
-        throw new FunctionNotExistException(getName(), functionPath);
+    public boolean functionExists(ObjectPath objectPath) throws 
CatalogException {
+        return 
BUILTIN_BITMAP_FUNCTIONS.containsKey(objectPath.getObjectName().toLowerCase());
     }
 
     @Override
-    public boolean functionExists(ObjectPath objectPath) throws 
CatalogException {
-        return false;
+    public CatalogFunction getFunction(ObjectPath functionPath)
+            throws FunctionNotExistException, CatalogException {
+        String className = 
BUILTIN_BITMAP_FUNCTIONS.get(functionPath.getObjectName().toLowerCase());

Review Comment:
   uses the default locale.. `maybe use toLowerCase(Locale.ROOT)`?



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/functions/bitmap/RbAndAggFunction.java:
##########
@@ -0,0 +1,305 @@
+/*
+ * 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.fluss.exception.FlussRuntimeException;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.SimpleTypeSerializerSnapshot;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+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.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 javax.annotation.concurrent.ThreadSafe;
+
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * {@code rb_and_agg(bitmap BYTES) -> BYTES}
+ *
+ * <p>Intersects multiple serialized {@link RoaringBitmap} values using 
bitwise AND across rows.
+ *
+ * <p>Unlike {@link RbOrAggFunction}, this function requires a custom {@link 
Accumulator} that
+ * carries an {@code initialized} flag alongside the bitmap. This is necessary 
because an empty
+ * bitmap cannot be used as a sentinel for "no input received yet": once the 
AND result becomes the
+ * empty set, it must stay empty even if further inputs arrive, whereas a 
truly uninitialized
+ * accumulator must be seeded with the first input via OR before AND can 
proceed.
+ *
+ * <p>Note: there is no server-side {@code FieldRoaringBitmapAndAgg} 
counterpart. This function
+ * executes entirely in Flink. Users should be aware that combining it with 
{@code
+ * table.merge-engine=aggregation} may produce unexpected results during 
server-side compaction.
+ *
+ * <p>Returns {@code null} when all inputs are null or the input set is empty.
+ */
+@FunctionHint(
+        accumulator = @DataTypeHint(value = "RAW", bridgedTo = 
RbAndAggFunction.Accumulator.class))
+public class RbAndAggFunction extends AggregateFunction<byte[], 
RbAndAggFunction.Accumulator> {

Review Comment:
   RbAndAggFunction has no retract; the other two throw a clear 
UnsupportedOperationException. In a non-append-only GROUP BY, Flink will fail 
with a less obvious message. Consider adding an explicit throwing retract for 
symmetry and clearer errors.
   



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/catalog/FlinkCatalog.java:
##########
@@ -134,6 +136,18 @@ public class FlinkCatalog extends AbstractCatalog {
     protected Connection connection;
     protected Admin admin;
 
+    private static final Map<String, String> BUILTIN_BITMAP_FUNCTIONS;

Review Comment:
   could be wrapped in `Collections.unmodifiableMap` for safety.



-- 
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]

Reply via email to