Skip to content

Commit 1bb0ae6

Browse files
authored
Allow cuco::arrow_filter_policy to accept a custom implementation of xxhash_64 (#642)
1 parent d829576 commit 1bb0ae6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

include/cuco/bloom_filter_policies.cuh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <cuco/detail/bloom_filter/arrow_filter_policy.cuh>
2020
#include <cuco/detail/bloom_filter/default_filter_policy_impl.cuh>
21+
#include <cuco/hash_functions.cuh>
2122

2223
#include <cstdint>
2324

@@ -28,9 +29,12 @@ namespace cuco {
2829
* fingerprint.
2930
*
3031
* @tparam Key The type of the values to generate a fingerprint for.
32+
* @tparam XXHash64 Custom (64 bit) XXHash hasher to generate a key's fingerprint.
33+
* By default, cuco::xxhash_64 hasher will be used.
34+
*
3135
*/
32-
template <class Key>
33-
using arrow_filter_policy = detail::arrow_filter_policy<Key>;
36+
template <class Key, class XXHash64 = cuco::xxhash_64<Key>>
37+
using arrow_filter_policy = detail::arrow_filter_policy<Key, XXHash64>;
3438

3539
/**
3640
* @brief The default policy that defines how a Blocked Bloom Filter generates and stores a key's

include/cuco/detail/bloom_filter/arrow_filter_policy.cuh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ namespace cuco::detail {
7878
* @endcode
7979
*
8080
* @tparam Key The type of the values to generate a fingerprint for.
81+
* @tparam XXHash64 64-bit XXHash hasher implementation for fingerprint generation.
8182
*/
82-
template <class Key>
83+
template <class Key, class XXHash64>
8384
class arrow_filter_policy {
8485
public:
85-
using hasher = cuco::xxhash_64<Key>; ///< xxhash_64 hasher for Arrow bloom filter policy
86-
using word_type = std::uint32_t; ///< uint32_t for Arrow bloom filter policy
86+
using hasher = XXHash64; ///< 64-bit XXHash hasher for Arrow bloom filter policy
87+
using word_type = std::uint32_t; ///< uint32_t for Arrow bloom filter policy
8788
using hash_argument_type = typename hasher::argument_type; ///< Hash function input type
8889
using hash_result_type = decltype(std::declval<hasher>()(
8990
std::declval<hash_argument_type>())); ///< hash function output type

tests/bloom_filter/unique_sequence_test.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void test_unique_sequence(Filter& filter, size_type num_keys)
3535
{
3636
using Key = typename Filter::key_type;
3737

38+
// Generate keys
3839
thrust::device_vector<Key> keys(num_keys);
39-
4040
thrust::sequence(thrust::device, keys.begin(), keys.end());
4141

4242
thrust::device_vector<bool> contained(num_keys, false);
@@ -119,4 +119,4 @@ TEMPLATE_TEST_CASE_SIG("bloom_filter arrow policy tests",
119119
auto filter = filter_type{1000};
120120

121121
test_unique_sequence(filter, num_keys);
122-
}
122+
}

0 commit comments

Comments
 (0)