Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Nov 29, 2023
1 parent bf32a8f commit 6dc0aa5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 2 additions & 3 deletions cpp/src/parquet/bloom_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
25 changes: 13 additions & 12 deletions cpp/src/parquet/bloom_filter_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "parquet/bloom_filter.h"
Expand All @@ -25,27 +26,27 @@
namespace parquet::test {

TEST(BloomFilterReader, ReadBloomFilter) {
struct BloomFilterTestFile {
std::string filename;
bool has_bloom_filter_length;
};
std::vector<BloomFilterTestFile> files = {
{"data_index_bloom_encoding_stats.parquet", false},
{"data_index_bloom_encoding_with_length.parquet", false},
};
std::vector<std::string> 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
{
Expand Down

0 comments on commit 6dc0aa5

Please sign in to comment.