You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2024/11/11 03:43:02 UTC
Re: [PR] GH-34785: [C++][Parquet] Parquet Bloom Filter Writer Implementation [arrow]
mapleFU commented on code in PR #37400:
URL: https://github.com/apache/arrow/pull/37400#discussion_r1835917429
##########
cpp/src/parquet/arrow/arrow_reader_writer_test.cc:
##########
@@ -5723,5 +5731,213 @@ TEST_F(ParquetPageIndexRoundTripTest, EnablePerColumn) {
/*null_counts=*/{0}}));
}
+class ParquetBloomFilterRoundTripTest : public ::testing::Test,
+ public ParquetIndexRoundTripTest {
+ public:
+ void ReadBloomFilters(int expect_num_row_groups,
+ const std::set<int>& expect_columns_without_filter = {}) {
+ auto reader = ParquetFileReader::Open(std::make_shared<BufferReader>(buffer_));
+
+ auto metadata = reader->metadata();
+ ASSERT_EQ(expect_num_row_groups, metadata->num_row_groups());
+
+ auto& bloom_filter_reader = reader->GetBloomFilterReader();
+
+ for (int rg = 0; rg < metadata->num_row_groups(); ++rg) {
+ auto row_group_reader = bloom_filter_reader.RowGroup(rg);
+ ASSERT_NE(row_group_reader, nullptr);
+
+ for (int col = 0; col < metadata->num_columns(); ++col) {
+ bool expect_no_bloom_filter = expect_columns_without_filter.find(col) !=
+ expect_columns_without_filter.cend();
+
+ auto bloom_filter = row_group_reader->GetColumnBloomFilter(col);
+ if (expect_no_bloom_filter) {
+ ASSERT_EQ(nullptr, bloom_filter);
+ } else {
+ ASSERT_NE(nullptr, bloom_filter);
+ bloom_filters_.push_back(std::move(bloom_filter));
+ }
+ }
+ }
+ }
+
+ template <typename ArrowType>
+ void VerifyBloomFilter(const BloomFilter* bloom_filter,
+ const ::arrow::ChunkedArray& chunked_array) {
+ for (auto value : ::arrow::stl::Iterate<ArrowType>(chunked_array)) {
+ if (value == std::nullopt) {
+ continue;
+ }
+ EXPECT_TRUE(bloom_filter->FindHash(bloom_filter->Hash(value.value())));
Review Comment:
Refer to VerifyBloomFilterNotContains?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org