cloud-fan commented on code in PR #41623:
URL: https://github.com/apache/spark/pull/41623#discussion_r1236907574


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/bitmapExpressions.scala:
##########
@@ -0,0 +1,318 @@
+/*
+ * 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.spark.sql.catalyst.expressions
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
+import org.apache.spark.sql.catalyst.expressions.aggregate.ImperativeAggregate
+import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
+import org.apache.spark.sql.catalyst.trees.UnaryLike
+import org.apache.spark.sql.types.{AbstractDataType, BinaryType, DataType, 
LongType, StructType}
+
+/** Shared constants and methods for bitmap functions. */
+object BitmapFunctions {
+  /** Number of bytes in a bitmap. */
+  final val NUM_BYTES = 4 * 1024
+
+  /** Number of bits in a bitmap. */
+  final val NUM_BITS = 8 * NUM_BYTES
+
+  /** Merges both bitmaps and writes into bitmap1. */
+  def merge(bitmap1: Array[Byte], bitmap2: Array[Byte]): Unit = {
+    for (i <- 0 until Math.min(bitmap1.length, bitmap2.length)) {
+      bitmap1.update(i, ((bitmap1(i) & 0x0FF) | (bitmap2(i) & 0x0FF)).toByte)
+    }
+  }
+}
+
+@ExpressionDescription(
+  usage = "_FUNC_(child) - Returns the bucket number for the given input child 
expression.",
+  examples = """
+    Examples:
+      > SELECT _FUNC_(123);
+       1
+      > SELECT _FUNC_(0);
+       0
+  """,
+  since = "3.5.0",
+  group = "misc_funcs"
+)
+case class BitmapBucketNumber(child: Expression)
+  extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant with 
CodegenFallback {

Review Comment:
   It's more recommended to implement an expression with a static java method. 
See `AesEncrypt` as an example.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to