diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 26b7ee68aad7..a402333db81e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -706,6 +706,7 @@ add_library( src/hash/md5_hash.cu src/hash/murmurhash3_x86_32.cu src/hash/murmurhash3_x64_128.cu + src/hash/spark_murmurhash3_x86_32.cu src/hash/sha1_hash.cu src/hash/sha224_hash.cu src/hash/sha256_hash.cu diff --git a/cpp/include/cudf/detail/row_operator/spark_hashing.cuh b/cpp/include/cudf/detail/row_operator/spark_hashing.cuh new file mode 100644 index 000000000000..54c74c15a6fb --- /dev/null +++ b/cpp/include/cudf/detail/row_operator/spark_hashing.cuh @@ -0,0 +1,135 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +namespace CUDF_EXPORT cudf { +namespace detail::row::hash { + +/** + * @brief Computes row hashes using Spark's iterative seeding convention. + * + * Spark uses the hash of each value as the seed for the next value and ignores + * null values. Consequently, values of different nested shapes can collide. + * For example, the integer `1`, the list `[1]`, and a struct containing only + * `1` have the same hash. Likewise, `[1]`, `[1, null]`, and `[null, 1]` have + * the same hash. A null element returns its input seed unchanged. + * + * The element hash function is responsible for Spark-specific type encodings + * and hash algorithm behavior. + * + * LIST columns whose child is a STRUCT are unsupported and must be rejected + * before invoking this hasher. + * + * @tparam hash_function Seeded element hash functor with a `result_type` member + * @tparam Nullate A cudf::nullate type describing whether to check for nulls + */ +template