cloud-fan commented on a change in pull request #34077:
URL: https://github.com/apache/spark/pull/34077#discussion_r715465959
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala
##########
@@ -60,6 +61,57 @@ class SQLOpenHashSet[@specialized(Long, Int, Double, Float)
T: ClassTag](
}
object SQLOpenHashSet {
+ def withNullCheckFunc(
+ dataType: DataType,
+ hashSet: SQLOpenHashSet[Any],
+ handleNotNull: Any => Unit,
+ handleNull: () => Unit): ArrayData => Int => Unit = {
+ (array: ArrayData) => {
+ (index: Int) =>
+ if (array.isNullAt(index)) {
+ if (!hashSet.containsNull) {
+ hashSet.addNull
+ handleNull()
+ }
+ } else {
+ val elem = array.get(index, dataType)
+ handleNotNull(elem)
+ }
+ }
+ }
+
+ def withNullCheckCode(
+ arrayType1: DataType,
+ arrayType2: DataType,
Review comment:
let's document it clearly. I think we can just pass 2 boolean:
`arrayContainsNull: Boolean, setContainsNull: Boolean`
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/util/SQLOpenHashSet.scala
##########
@@ -60,6 +61,57 @@ class SQLOpenHashSet[@specialized(Long, Int, Double, Float)
T: ClassTag](
}
object SQLOpenHashSet {
+ def withNullCheckFunc(
+ dataType: DataType,
+ hashSet: SQLOpenHashSet[Any],
+ handleNotNull: Any => Unit,
+ handleNull: () => Unit): ArrayData => Int => Unit = {
+ (array: ArrayData) => {
+ (index: Int) =>
+ if (array.isNullAt(index)) {
+ if (!hashSet.containsNull) {
+ hashSet.addNull
+ handleNull()
+ }
+ } else {
+ val elem = array.get(index, dataType)
+ handleNotNull(elem)
+ }
+ }
+ }
+
+ def withNullCheckCode(
+ arrayType1: DataType,
+ arrayType2: DataType,
Review comment:
I think we can just pass 2 boolean: `arrayContainsNull: Boolean,
setContainsNull: Boolean`
--
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]