Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wgtmac committed Jul 1, 2024
1 parent 82f4b34 commit a03caef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cpp/src/parquet/page_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/size_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ std::unique_ptr<SizeStatistics> 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) {
Expand Down
9 changes: 5 additions & 4 deletions cpp/src/parquet/size_statistics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <gtest/gtest.h>

#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"
Expand All @@ -32,14 +33,13 @@

namespace parquet {

using namespace parquet::schema;

TEST(SizeStatistics, WriteBatchLevels) {
std::vector<int64_t> expected_def_level_histogram = {256, 128, 64, 32, 16, 8, 4, 2, 2};
std::vector<int64_t> expected_rep_level_histogram = {256, 128, 64, 32, 32};
constexpr int16_t kMaxDefLevel = 8;
constexpr int16_t kMaxRefLevel = 4;
auto descr = std::make_unique<ColumnDescriptor>(Int32("a"), kMaxDefLevel, kMaxRefLevel);
auto descr =
std::make_unique<ColumnDescriptor>(schema::Int32("a"), kMaxDefLevel, kMaxRefLevel);
auto builder = SizeStatisticsBuilder::Make(descr.get());

auto write_batch_levels =
Expand Down Expand Up @@ -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<ColumnDescriptor>(Int32("a"), kMaxDefLevel, kMaxRepLevel);
auto descr =
std::make_unique<ColumnDescriptor>(schema::Int32("a"), kMaxDefLevel, kMaxRepLevel);
auto builder = SizeStatisticsBuilder::Make(descr.get());

constexpr int64_t kNumRounds = 10;
Expand Down

0 comments on commit a03caef

Please sign in to comment.