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

Method WriteTestData

cpp/src/parquet/reader_test.cc:1957–1989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1955 const int kNumRows = 1000;
1956
1957 void WriteTestData(std::shared_ptr<const LogicalType> type, bool write_arrow) {
1958 // Make schema
1959 schema::NodeVector fields;
1960 fields.push_back(
1961 PrimitiveNode::Make("g", Repetition::REQUIRED, type, Type::BYTE_ARRAY));
1962 auto schema = std::static_pointer_cast<GroupNode>(
1963 GroupNode::Make("schema", Repetition::REQUIRED, fields));
1964
1965 // Write small batches and small data pages
1966 auto writer_props_builder = WriterProperties::Builder();
1967 writer_props_builder.write_batch_size(64);
1968
1969 std::shared_ptr<WriterProperties> writer_props = writer_props_builder.build();
1970
1971 ASSERT_OK_AND_ASSIGN(auto out_file, ::arrow::io::BufferOutputStream::Create());
1972 std::shared_ptr<ParquetFileWriter> file_writer =
1973 ParquetFileWriter::Open(out_file, schema, writer_props);
1974 RowGroupWriter* rg_writer = file_writer->AppendRowGroup();
1975
1976 // write WKB points to columns
1977 auto* writer =
1978 ::arrow::internal::checked_cast<ByteArrayWriter*>(rg_writer->NextColumn());
1979 if (!write_arrow) {
1980 WriteTestDataUsingWriteBatch(writer);
1981 } else {
1982 WriteTestDataUsingWriteArrow(writer);
1983 }
1984
1985 rg_writer->Close();
1986 file_writer->Close();
1987
1988 ASSERT_OK_AND_ASSIGN(file_buf, out_file->Finish());
1989 }
1990
1991 void WriteTestDataUsingWriteBatch(ByteArrayWriter* writer) {
1992 std::vector<uint8_t> buffer(test::kWkbPointXYSize * kNumRows);

Callers

nothing calls this directly

Calls 9

push_backMethod · 0.80
MakeFunction · 0.70
BuilderFunction · 0.70
ASSERT_OK_AND_ASSIGNFunction · 0.70
buildMethod · 0.45
AppendRowGroupMethod · 0.45
NextColumnMethod · 0.45
CloseMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected