From a03caef6e30376243638f680a3103a1c2f0c5c73 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Mon, 24 Jun 2024 23:34:17 +0800 Subject: [PATCH] fix tests --- cpp/src/parquet/page_index.cc | 4 ++-- cpp/src/parquet/size_statistics.cc | 2 +- cpp/src/parquet/size_statistics_test.cc | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cpp/src/parquet/page_index.cc b/cpp/src/parquet/page_index.cc index b9959f8b4aaf2..3175bfe8f6f35 100644 --- a/cpp/src/parquet/page_index.cc +++ b/cpp/src/parquet/page_index.cc @@ -519,7 +519,7 @@ class ColumnIndexBuilderImpl final : public ColumnIndexBuilder { column_index_.null_counts.clear(); } - if (size_stats) { + if (size_stats != nullptr) { const auto& page_ref_level_hist = size_stats->repetition_level_histogram(); const auto& page_def_level_hist = size_stats->definition_level_histogram(); column_index_.repetition_level_histograms.insert( @@ -696,7 +696,7 @@ class OffsetIndexBuilderImpl final : public OffsetIndexBuilder { if (offset_index_.page_locations.size() == offset_index_.unencoded_byte_array_data_bytes.size()) { offset_index_.__isset.unencoded_byte_array_data_bytes = true; - } else { + } else if (!offset_index_.unencoded_byte_array_data_bytes.empty()) { std::stringstream ss; ss << "Invalid count of unencoded BYTE_ARRAY data bytes: " << offset_index_.unencoded_byte_array_data_bytes.size() diff --git a/cpp/src/parquet/size_statistics.cc b/cpp/src/parquet/size_statistics.cc index 819b45a57616f..45273d123fdff 100644 --- a/cpp/src/parquet/size_statistics.cc +++ b/cpp/src/parquet/size_statistics.cc @@ -113,7 +113,7 @@ std::unique_ptr SizeStatistics::Make(const void* size_statistics class SizeStatisticsBuilder::SizeStatisticsBuilderImpl { public: - SizeStatisticsBuilderImpl(const ColumnDescriptor* descr) + explicit SizeStatisticsBuilderImpl(const ColumnDescriptor* descr) : rep_level_histogram_(descr->max_repetition_level() + 1, 0), def_level_histogram_(descr->max_definition_level() + 1, 0) { if (descr->physical_type() == Type::BYTE_ARRAY) { diff --git a/cpp/src/parquet/size_statistics_test.cc b/cpp/src/parquet/size_statistics_test.cc index 3184a92ecd482..b8073b65cba24 100644 --- a/cpp/src/parquet/size_statistics_test.cc +++ b/cpp/src/parquet/size_statistics_test.cc @@ -23,6 +23,7 @@ #include #include "arrow/buffer.h" +#include "arrow/testing/builder.h" #include "arrow/testing/gtest_util.h" #include "arrow/util/bit_util.h" #include "parquet/schema.h" @@ -32,14 +33,13 @@ namespace parquet { -using namespace parquet::schema; - TEST(SizeStatistics, WriteBatchLevels) { std::vector expected_def_level_histogram = {256, 128, 64, 32, 16, 8, 4, 2, 2}; std::vector expected_rep_level_histogram = {256, 128, 64, 32, 32}; constexpr int16_t kMaxDefLevel = 8; constexpr int16_t kMaxRefLevel = 4; - auto descr = std::make_unique(Int32("a"), kMaxDefLevel, kMaxRefLevel); + auto descr = + std::make_unique(schema::Int32("a"), kMaxDefLevel, kMaxRefLevel); auto builder = SizeStatisticsBuilder::Make(descr.get()); auto write_batch_levels = @@ -73,7 +73,8 @@ TEST(SizeStatistics, WriteBatchLevels) { TEST(SizeStatistics, WriteRepeatedLevels) { constexpr int16_t kMaxDefLevel = 2; constexpr int16_t kMaxRepLevel = 3; - auto descr = std::make_unique(Int32("a"), kMaxDefLevel, kMaxRepLevel); + auto descr = + std::make_unique(schema::Int32("a"), kMaxDefLevel, kMaxRepLevel); auto builder = SizeStatisticsBuilder::Make(descr.get()); constexpr int64_t kNumRounds = 10;