MCPcopy Create free account
hub / github.com/apache/arrow / TEST_P

Function TEST_P

cpp/src/parquet/column_reader_test.cc:737–777  ·  view source on GitHub ↗

Tests reading a required field. The expected results are the same for reading dense and spaced.

Source from the content-addressed store, hash-verified

735// Tests reading a required field. The expected results are the same for
736// reading dense and spaced.
737TEST_P(RecordReaderPrimitiveTypeTest, ReadRequired) {
738 Init(schema::Int32("b", Repetition::REQUIRED));
739
740 // Records look like: {10, 20, 20, 30, 30, 30}
741 std::vector<std::shared_ptr<Page>> pages;
742 std::vector<int32_t> values = {10, 20, 20, 30, 30, 30};
743 std::vector<int16_t> def_levels = {};
744 std::vector<int16_t> rep_levels = {};
745
746 std::shared_ptr<DataPageV1> page = MakeDataPage<Int32Type>(
747 descr_, values, /*num_values=*/static_cast<int>(def_levels.size()), Encoding::PLAIN,
748 /*indices=*/{},
749 /*indices_size=*/0, def_levels, descr_->max_definition_level(), rep_levels,
750 descr_->max_repetition_level());
751 pages.push_back(std::move(page));
752 auto pager = std::make_unique<MockPageReader>(pages);
753 record_reader_->SetPageReader(std::move(pager));
754
755 // Read [10]
756 int64_t records_read = record_reader_->ReadRecords(/*num_records=*/1);
757 ASSERT_EQ(records_read, 1);
758 CheckState(/*values_written=*/1, /*null_count=*/0, /*levels_written=*/0,
759 /*levels_position=*/0);
760 CheckReadValues(/*expected_values=*/{10}, /*expected_defs=*/{},
761 /*expected_reps=*/{});
762 record_reader_->Reset();
763 CheckState(/*values_written=*/0, /*null_count=*/0, /*levels_written=*/0,
764 /*levels_position=*/0);
765
766 // Read 20, 20, 30, 30, 30
767 records_read = record_reader_->ReadRecords(/*num_records=*/10);
768 ASSERT_EQ(records_read, 5);
769 CheckState(/*values_written=*/5, /*null_count=*/0, /*levels_written=*/0,
770 /*levels_position=*/0);
771 CheckReadValues(/*expected_values=*/{20, 20, 30, 30, 30},
772 /*expected_defs=*/{},
773 /*expected_reps=*/{});
774 record_reader_->Reset();
775 CheckState(/*values_written=*/0, /*null_count=*/0, /*levels_written=*/0,
776 /*levels_position=*/0);
777}
778
779// Tests reading an optional field.
780// Use a max definition field > 1 to test both cases where parent is present or

Callers

nothing calls this directly

Calls 14

to_stringFunction · 0.85
vector_equalFunction · 0.85
push_backMethod · 0.80
SetPageReaderMethod · 0.80
ReadRecordsMethod · 0.80
SkipRecordsMethod · 0.80
emplace_backMethod · 0.80
MakeFunction · 0.70
sizeMethod · 0.45
ResetMethod · 0.45
descrMethod · 0.45
null_countMethod · 0.45

Tested by

no test coverage detected