Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Nov 24, 2023
1 parent e5875e9 commit 3a87383
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
9 changes: 9 additions & 0 deletions cpp/src/parquet/bloom_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ 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.
std::stringstream ss;
ss << "Bloom filter length (" << bloom_filter_length.value()
<< ") is not enough to read the entire bloom filter (size: "
<< bloom_filter_size + header_size << ").";
throw ParquetException(ss.str());
}
// We have read a part of the bloom filter already, copy it to the target buffer
// and read the remaining part from the InputStream.
auto buffer = AllocateBuffer(properties.memory_pool(), bloom_filter_size);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/parquet/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ class PARQUET_EXPORT BlockSplitBloomFilter : public BloomFilter {
/// a Bloom filter from a parquet filter.
///
/// @param properties The parquet reader properties.
/// @param input_stream The input stream from which to construct the Bloom filter.
/// @param bloom_filter_length The length of the Serialized Bloom filter including
/// @param input_stream The input stream from which to construct the bloom filter.
/// @param bloom_filter_length The length of the serialized bloom filter including
/// header.
/// @return The BlockSplitBloomFilter.
static BlockSplitBloomFilter Deserialize(
Expand Down
16 changes: 8 additions & 8 deletions cpp/src/parquet/printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,19 @@ void ParquetFilePrinter::JSONPrint(std::ostream& stream, std::list<int> selected
stream << "\"}";
}

if (column_chunk->GetOffsetIndexLocation()) {
auto location = column_chunk->GetOffsetIndexLocation().value();
// Output OffsetIndex {offset, length}
stream << "\", OffsetIndex {"
if (column_chunk->GetColumnIndexLocation()) {
auto location = column_chunk->GetColumnIndexLocation().value();
// Output ColumnIndex {offset, length}
stream << "\", ColumnIndex {"
<< "\"offset\": \"" << location.offset;
stream << "\", \"length\": \"" << location.length;
stream << "\"}";
}

if (column_chunk->GetColumnIndexLocation()) {
auto location = column_chunk->GetColumnIndexLocation().value();
// Output ColumnIndex {offset, length}
stream << "\", ColumnIndex {"
if (column_chunk->GetOffsetIndexLocation()) {
auto location = column_chunk->GetOffsetIndexLocation().value();
// Output OffsetIndex {offset, length}
stream << "\", OffsetIndex {"
<< "\"offset\": \"" << location.offset;
stream << "\", \"length\": \"" << location.length;
stream << "\"}";
Expand Down

0 comments on commit 3a87383

Please sign in to comment.