mbutrovich commented on code in PR #7691:
URL: https://github.com/apache/datafusion-comet/pull/7691#discussion_r4635751180


##########
native/spark-expr/src/hash_funcs/utils.rs:
##########
@@ -1499,3 +1558,131 @@ mod tests {
         }
     }
 }
+
+#[cfg(test)]
+mod null_chunk_tests {

Review Comment:
   Thanks, moved them into `mod tests`, and `MIN_VALID_FOR_DENSE` is private 
now.



##########
native/spark-expr/benches/hash_nulls.rs:
##########
@@ -0,0 +1,129 @@
+// 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.
+
+//! Benchmarks hashing fixed-width columns with nulls, the case shuffle hash 
partitioning hits on
+//! nullable keys such as TPC-DS foreign keys.
+
+use arrow::array::{ArrayRef, Float64Array, Int32Array, Int64Array};
+use arrow::buffer::NullBuffer;
+use criterion::{criterion_group, criterion_main, Criterion};
+use datafusion::common::ScalarValue;
+use datafusion::physical_plan::ColumnarValue;
+use datafusion_comet_spark_expr::murmur3::create_murmur3_hashes;
+use datafusion_comet_spark_expr::spark_xxhash64;
+use std::hint::black_box;
+use std::sync::Arc;
+
+const NUM_ROWS: usize = 8192;
+
+/// Null percentages, from TPC-DS-like to nearly all null.
+const SWEEP: [u32; 11] = [3, 10, 25, 50, 60, 70, 75, 80, 85, 90, 99];
+
+/// Pseudo-random values from a fixed-seed xorshift, so runs are comparable.
+fn xorshift(seed: u64) -> impl FnMut() -> u64 {
+    let mut x = seed;
+    move || {
+        x ^= x << 13;
+        x ^= x >> 7;
+        x ^= x << 17;
+        x
+    }
+}
+
+/// Each row is null with probability `null_fraction`, independently.
+fn random_nulls(null_fraction: f64) -> NullBuffer {
+    let mut next = xorshift(0x2545_f491_4f6c_dd1d);
+    NullBuffer::from(
+        (0..NUM_ROWS)
+            .map(|_| (next() as f64 / u64::MAX as f64) >= null_fraction)
+            .collect::<Vec<_>>(),
+    )
+}
+
+/// Every tenth row is null, a pattern the branch predictor learns.
+fn stride_nulls() -> NullBuffer {

Review Comment:
   Thanks, switched to `common::i32_array`.



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