-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Support reading bloom filters from Parquet files and filter row group…
…s using them (#17289) This PR adds support to read bloom filters from Parquet files and use them to filter row groups based on `col == literal` like predicate(s), if provided. Related to #17164 Authors: - Muhammad Haseeb (https://github.com/mhaseeb123) Approvers: - Yunsong Wang (https://github.com/PointKernel) - Vukasin Milovanovic (https://github.com/vuule) - Karthikeyan (https://github.com/karthikeyann) - Bradley Dice (https://github.com/bdice) URL: #17289
1 parent
fe75cb8
commit 41215e2
Showing
16 changed files
with
1,098 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_utilities.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/iterator_utilities.hpp> | ||
|
||
#include <cudf/detail/cuco_helpers.hpp> | ||
#include <cudf/hashing.hpp> | ||
#include <cudf/hashing/detail/xxhash_64.cuh> | ||
#include <cudf/utilities/default_stream.hpp> | ||
|
||
#include <cuco/bloom_filter.cuh> | ||
#include <cuco/bloom_filter_policies.cuh> | ||
|
||
using StringType = cudf::string_view; | ||
|
||
class ParquetBloomFilterTest : public cudf::test::BaseFixture {}; | ||
|
||
TEST_F(ParquetBloomFilterTest, TestStrings) | ||
{ | ||
using key_type = StringType; | ||
using policy_type = cuco::arrow_filter_policy<key_type, cudf::hashing::detail::XXHash_64>; | ||
using word_type = policy_type::word_type; | ||
|
||
std::size_t constexpr num_filter_blocks = 4; | ||
auto stream = cudf::get_default_stream(); | ||
|
||
// strings keys to insert | ||
auto keys = cudf::test::strings_column_wrapper( | ||
{"seventh", "fifteenth", "second", "tenth", "fifth", "first", | ||
"seventh", "tenth", "ninth", "ninth", "seventeenth", "eighteenth", | ||
"thirteenth", "fifth", "fourth", "twelfth", "second", "second", | ||
"fourth", "seventh", "seventh", "tenth", "thirteenth", "seventeenth", | ||
"fifth", "seventeenth", "eighth", "fourth", "second", "eighteenth", | ||
"fifteenth", "second", "seventeenth", "thirteenth", "eighteenth", "fifth", | ||
"seventh", "tenth", "fourteenth", "first", "fifth", "fifth", | ||
"tenth", "thirteenth", "fourteenth", "third", "third", "sixth", | ||
"first", "third"}); | ||
|
||
auto d_keys = cudf::column_device_view::create(keys); | ||
|
||
// Spawn a bloom filter | ||
cuco::bloom_filter<key_type, | ||
cuco::extent<size_t>, | ||
cuda::thread_scope_device, | ||
policy_type, | ||
cudf::detail::cuco_allocator<char>> | ||
filter{num_filter_blocks, | ||
cuco::thread_scope_device, | ||
{{cudf::DEFAULT_HASH_SEED}}, | ||
cudf::detail::cuco_allocator<char>{rmm::mr::polymorphic_allocator<char>{}, stream}, | ||
stream}; | ||
|
||
// Add strings to the bloom filter | ||
filter.add(d_keys->begin<key_type>(), d_keys->end<key_type>(), stream); | ||
|
||
// Number of words in the filter | ||
cudf::size_type const num_words = filter.block_extent() * filter.words_per_block; | ||
|
||
// Filter bitset as a column | ||
auto const bitset = cudf::column_view{ | ||
cudf::data_type{cudf::type_id::UINT32}, num_words, filter.data(), nullptr, 0, 0, {}}; | ||
|
||
// Expected filter bitset words computed using Arrow's implementation here: | ||
// https://godbolt.org/z/oKfqcPWbY | ||
auto expected = cudf::test::fixed_width_column_wrapper<word_type>( | ||
{4194306U, 4194305U, 2359296U, 1073774592U, 524544U, 1024U, 268443648U, | ||
8519680U, 2147500040U, 8421380U, 269500416U, 4202624U, 8396802U, 100665344U, | ||
2147747840U, 5243136U, 131146U, 655364U, 285345792U, 134222340U, 545390596U, | ||
2281717768U, 51201U, 41943553U, 1619656708U, 67441680U, 8462730U, 361220U, | ||
2216738864U, 587333888U, 4219272U, 873463873U}); | ||
|
||
// Check the bitset for equality | ||
CUDF_TEST_EXPECT_COLUMNS_EQUAL(bitset, expected); | ||
} |
Binary file added
BIN
+40.5 KB
python/cudf/cudf/tests/data/parquet/mixed_card_ndv_100_bf_fpp0.1_nostats.snappy.parquet
Binary file not shown.
Binary file added
BIN
+36.2 KB
python/cudf/cudf/tests/data/parquet/mixed_card_ndv_100_chunk_stats.snappy.parquet
Binary file not shown.
Binary file added
BIN
+76.2 KB
python/cudf/cudf/tests/data/parquet/mixed_card_ndv_500_bf_fpp0.1_nostats.snappy.parquet
Binary file not shown.
Binary file added
BIN
+56.8 KB
python/cudf/cudf/tests/data/parquet/mixed_card_ndv_500_chunk_stats.snappy.parquet
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters