From 6bfa3c449eb570363b604b02a36e40ba6681895b Mon Sep 17 00:00:00 2001 From: mwish Date: Mon, 8 Apr 2024 21:34:03 +0800 Subject: [PATCH] fix comment --- cpp/src/parquet/encoding_test.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cpp/src/parquet/encoding_test.cc b/cpp/src/parquet/encoding_test.cc index bc11a419c7e50..06e9ef555bcce 100644 --- a/cpp/src/parquet/encoding_test.cc +++ b/cpp/src/parquet/encoding_test.cc @@ -661,7 +661,7 @@ class TestBooleanArrowDecoding : public ::testing::Test { // Initialize input_data_ for the encoder from the expected_array_ values const auto& boolean_array = - static_cast(*expected_dense_); + checked_cast(*expected_dense_); input_data_.resize(boolean_array.length()); for (int64_t i = 0; i < boolean_array.length(); ++i) { @@ -680,6 +680,11 @@ class TestBooleanArrowDecoding : public ::testing::Test { ASSERT_NO_THROW(encoder_->Put(data_ptr, kNumValues)); } buffer_ = encoder_->FlushValues(); + ResetTheDecoder(); + } + + void ResetTheDecoder() { + ASSERT_NE(nullptr, buffer_); decoder_->SetData(kNumValues, buffer_->data(), static_cast(buffer_->size())); } @@ -688,12 +693,12 @@ class TestBooleanArrowDecoding : public ::testing::Test { ASSERT_ARRAYS_EQUAL(chunk, *expected_dense_); } - void CheckDecodeArrowUsingDenseBuilder(Encoding::type encoding) { + void CheckDecodeArrow(Encoding::type encoding) { for (double np : null_probabilities_) { for (double true_prob : true_probabilities_) { + InitTestCase(encoding, np, true_prob); for (int read_batch_size : this->read_batch_sizes_) { - // Resume the state of decoder - InitTestCase(encoding, np, true_prob); + ResetTheDecoder(); int num_values_left = kNumValues; ::arrow::BooleanBuilder acc; @@ -722,12 +727,13 @@ class TestBooleanArrowDecoding : public ::testing::Test { } } - void CheckDecodeArrowNonNullUsingDenseBuilder(Encoding::type encoding) { + void CheckDecodeArrowNonNull(Encoding::type encoding) { // NonNull skips tests for null_prob != 0. for (auto true_prob : true_probabilities_) { + InitTestCase(encoding, /*null_probability=*/0, true_prob); for (int read_batch_size : this->read_batch_sizes_) { // Resume the decoder - InitTestCase(encoding, /*null_probability=*/0, true_prob); + ResetTheDecoder(); ::arrow::BooleanBuilder acc; int actual_num_values = 0; int num_values_left = kNumValues; @@ -758,19 +764,19 @@ class TestBooleanArrowDecoding : public ::testing::Test { }; TEST_F(TestBooleanArrowDecoding, CheckDecodeArrowUsingDenseBuilderPlain) { - this->CheckDecodeArrowUsingDenseBuilder(Encoding::PLAIN); + this->CheckDecodeArrow(Encoding::PLAIN); } TEST_F(TestBooleanArrowDecoding, CheckDecodeArrowNonNullDenseBuilderPlain) { - this->CheckDecodeArrowNonNullUsingDenseBuilder(Encoding::PLAIN); + this->CheckDecodeArrowNonNull(Encoding::PLAIN); } TEST_F(TestBooleanArrowDecoding, CheckDecodeArrowUsingDenseBuilderRle) { - this->CheckDecodeArrowUsingDenseBuilder(Encoding::RLE); + this->CheckDecodeArrow(Encoding::RLE); } TEST_F(TestBooleanArrowDecoding, CheckDecodeArrowNonNullDenseBuilder) { - this->CheckDecodeArrowNonNullUsingDenseBuilder(Encoding::RLE); + this->CheckDecodeArrowNonNull(Encoding::RLE); } template