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

Function TEST_P

contrib/pax_storage/src/cpp/storage/orc/orc_test.cc:755–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753class OrcCompressTest : public OrcEncodingTest {};
754
755TEST_P(OrcEncodingTest, ReadTupleWithEncoding) {
756 TupleTableSlot *tuple_slot = nullptr;
757 auto encoding_kind = GetParam();
758
759 auto tuple_desc = reinterpret_cast<TupleDescData *>(
760 cbdb::Palloc0(sizeof(TupleDescData) + sizeof(FormData_pg_attribute) * 2));
761
762 tuple_desc->natts = 2;
763 InitAttribute_int8(&tuple_desc->attrs[0]);
764 InitAttribute_int8(&tuple_desc->attrs[1]);
765
766 tuple_slot = MakeTupleTableSlot(tuple_desc, &TTSOpsVirtual);
767 bool *fake_is_null =
768 reinterpret_cast<bool *>(cbdb::Palloc0(sizeof(bool) * COLUMN_NUMS));
769 fake_is_null[0] = false;
770 fake_is_null[1] = false;
771
772 tuple_slot->tts_values[0] = Int64GetDatum(0);
773 tuple_slot->tts_values[1] = Int64GetDatum(1);
774 tuple_slot->tts_isnull = fake_is_null;
775
776 auto local_fs = Singleton<LocalFileSystem>::GetInstance();
777 ASSERT_NE(nullptr, local_fs);
778
779 std::unique_ptr<File> file_ptr = local_fs->Open(file_name_, fs::kWriteMode);
780 EXPECT_NE(nullptr, file_ptr.get());
781
782 std::vector<pax::porc::proto::Type_Kind> types;
783 types.emplace_back(pax::porc::proto::Type_Kind::Type_Kind_LONG);
784 types.emplace_back(pax::porc::proto::Type_Kind::Type_Kind_LONG);
785 std::vector<std::tuple<ColumnEncoding_Kind, int>> types_encoding;
786 types_encoding.emplace_back(std::make_tuple(encoding_kind, 0));
787 types_encoding.emplace_back(std::make_tuple(encoding_kind, 0));
788 MicroPartitionWriter::WriterOptions writer_options;
789 writer_options.encoding_opts = types_encoding;
790 writer_options.rel_tuple_desc = tuple_desc;
791
792 auto writer = new OrcWriter(writer_options, types, std::move(file_ptr));
793
794 for (size_t i = 0; i < 10000; i++) {
795 tuple_slot->tts_values[0] = Int64GetDatum(i);
796 tuple_slot->tts_values[1] = Int64GetDatum(i + 1);
797 writer->WriteTuple(tuple_slot);
798 }
799
800 writer->Close();
801
802 file_ptr = local_fs->Open(file_name_, fs::kReadMode);
803
804 MicroPartitionReader::ReaderOptions reader_options;
805 auto reader = new OrcReader(std::move(file_ptr));
806 reader->Open(reader_options);
807 EXPECT_EQ(1UL, reader->GetGroupNums());
808 for (size_t i = 0; i < 10000; i++) {
809 ASSERT_TRUE(reader->ReadTuple(tuple_slot));
810 ASSERT_EQ(tuple_slot->tts_values[0], i);
811 ASSERT_EQ(tuple_slot->tts_values[1], i + 1);
812 }

Callers

nothing calls this directly

Calls 15

Palloc0Function · 0.85
InitAttribute_int8Function · 0.85
MakeTupleTableSlotFunction · 0.85
DeleteTestTupleTableSlotFunction · 0.85
InitAttribute_textFunction · 0.85
CreateTestTupleTableSlotFunction · 0.85
CreateTestSchemaTypesFunction · 0.85
VerifyTestTupleTableSlotFunction · 0.85
GetColumnsMethod · 0.80
SetColumnProjectionMethod · 0.80
Int64GetDatumFunction · 0.50
OpenMethod · 0.45

Tested by

no test coverage detected