zhztheplayer commented on code in PR #12614:
URL: https://github.com/apache/gluten/pull/12614#discussion_r3646600652
##########
backends-velox/src/main/scala/org/apache/gluten/expression/aggregate/VeloxBloomFilterAggregate.scala:
##########
@@ -55,14 +55,17 @@ case class VeloxBloomFilterAggregate(
override def prettyName: String = "velox_bloom_filter_agg"
- // Mark as lazy so that `estimatedNumItems` is not evaluated during tree
transformation.
- private lazy val estimatedNumItems: Long =
- Math.min(
- estimatedNumItemsExpression.eval().asInstanceOf[Number].longValue,
- SQLConf.get
- .getConfString("spark.sql.optimizer.runtime.bloomFilter.maxNumItems",
"4000000")
- .toLong
- )
+ // Mark as lazy so that `numBits` is not evaluated during tree
transformation. Sized the same
+ // way as the native `bloom_filter_agg` aggregate (capacity = min(numBits,
maxNumBits) / 16),
+ // so both engines agree on the resulting bit-array size for the same input
arguments,
+ // regardless of which engine executes the partial vs. final aggregation
stage.
+ private lazy val capacityFromNumBits: Int = {
+ val numBits = numBitsExpression.eval().asInstanceOf[Number].longValue
+ val maxNumBits = SQLConf.get
+ .getConfString("spark.sql.optimizer.runtime.bloomFilter.maxNumBits",
"67108864")
+ .toLong
+ Math.max(1, Math.toIntExact(Math.min(numBits, maxNumBits) / 16))
+ }
Review Comment:
Can we add a comment explaining how this code is aligned with Velox?
--
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]