From 6dc0aa538240d2bac6e14ba5c21e25690d765c0a Mon Sep 17 00:00:00 2001 From: mwish Date: Wed, 29 Nov 2023 19:01:41 +0800 Subject: [PATCH] fix comment --- cpp/src/parquet/bloom_filter.cc | 5 ++--- cpp/src/parquet/bloom_filter_reader_test.cc | 25 +++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cpp/src/parquet/bloom_filter.cc b/cpp/src/parquet/bloom_filter.cc index b1d552accc36e..c27e9670e8634 100644 --- a/cpp/src/parquet/bloom_filter.cc +++ b/cpp/src/parquet/bloom_filter.cc @@ -144,9 +144,8 @@ BlockSplitBloomFilter BlockSplitBloomFilter::Deserialize( bloom_filter.Init(header_buf->data() + header_size, bloom_filter_size); return bloom_filter; } - if (bloom_filter_length && *bloom_filter_length < bloom_filter_size + header_size) { - // We know the bloom filter data size, but the length is not enough to read the - // entire bloom filter. + if (bloom_filter_length && *bloom_filter_length != bloom_filter_size + header_size) { + // We know the bloom filter data size, but the real size is different. std::stringstream ss; ss << "Bloom filter length (" << bloom_filter_length.value() << ") is not enough to read the entire bloom filter (size: " diff --git a/cpp/src/parquet/bloom_filter_reader_test.cc b/cpp/src/parquet/bloom_filter_reader_test.cc index ddca9cb14e86e..f732b4a8e22b7 100644 --- a/cpp/src/parquet/bloom_filter_reader_test.cc +++ b/cpp/src/parquet/bloom_filter_reader_test.cc @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +#include #include #include "parquet/bloom_filter.h" @@ -25,27 +26,27 @@ namespace parquet::test { TEST(BloomFilterReader, ReadBloomFilter) { - struct BloomFilterTestFile { - std::string filename; - bool has_bloom_filter_length; - }; - std::vector files = { - {"data_index_bloom_encoding_stats.parquet", false}, - {"data_index_bloom_encoding_with_length.parquet", false}, - }; + std::vector files = {"data_index_bloom_encoding_stats.parquet", + "data_index_bloom_encoding_with_length.parquet"}; for (const auto& test_file : files) { std::string dir_string(parquet::test::get_data_dir()); - std::string path = dir_string + "/" + test_file.filename; - auto reader = ParquetFileReader::OpenFile(path, false); + std::string path = dir_string + "/" + test_file; + auto reader = ParquetFileReader::OpenFile(path, /*memory_map=*/false); auto file_metadata = reader->metadata(); EXPECT_FALSE(file_metadata->is_encryption_algorithm_set()); auto& bloom_filter_reader = reader->GetBloomFilterReader(); auto row_group_0 = bloom_filter_reader.RowGroup(0); ASSERT_NE(nullptr, row_group_0); - EXPECT_THROW(bloom_filter_reader.RowGroup(1), ParquetException); + EXPECT_THROW_THAT( + [&]() { bloom_filter_reader.RowGroup(1); }, ParquetException, + ::testing::Property(&ParquetException::what, + ::testing::HasSubstr("Invalid row group ordinal"))); auto bloom_filter = row_group_0->GetColumnBloomFilter(0); ASSERT_NE(nullptr, bloom_filter); - EXPECT_THROW(row_group_0->GetColumnBloomFilter(1), ParquetException); + EXPECT_THROW_THAT([&]() { row_group_0->GetColumnBloomFilter(1); }, ParquetException, + ::testing::Property(&ParquetException::what, + ::testing::HasSubstr( + "Invalid column index at column ordinal"))); // assert exists {