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

Method WriteTestData

cpp/src/parquet/reader_test.cc:2233–2265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2231 const int kNumRows = 1000;
2232
2233 void WriteTestData(std::shared_ptr<const LogicalType> type, bool write_arrow) {
2234 // Make schema
2235 schema::NodeVector fields;
2236 fields.push_back(
2237 PrimitiveNode::Make("g", Repetition::REQUIRED, type, Type::BYTE_ARRAY));
2238 auto schema = std::static_pointer_cast<GroupNode>(
2239 GroupNode::Make("schema", Repetition::REQUIRED, fields));
2240
2241 // Write small batches and small data pages
2242 auto writer_props_builder = WriterProperties::Builder();
2243 writer_props_builder.write_batch_size(64);
2244
2245 std::shared_ptr<WriterProperties> writer_props = writer_props_builder.build();
2246
2247 ASSERT_OK_AND_ASSIGN(auto out_file, ::arrow::io::BufferOutputStream::Create());
2248 std::shared_ptr<ParquetFileWriter> file_writer =
2249 ParquetFileWriter::Open(out_file, schema, writer_props);
2250 RowGroupWriter* rg_writer = file_writer->AppendRowGroup();
2251
2252 // write WKB points to columns
2253 auto* writer =
2254 ::arrow::internal::checked_cast<ByteArrayWriter*>(rg_writer->NextColumn());
2255 if (!write_arrow) {
2256 WriteTestDataUsingWriteBatch(writer);
2257 } else {
2258 WriteTestDataUsingWriteArrow(writer);
2259 }
2260
2261 rg_writer->Close();
2262 file_writer->Close();
2263
2264 ASSERT_OK_AND_ASSIGN(file_buf, out_file->Finish());
2265 }
2266
2267 void WriteTestDataUsingWriteBatch(ByteArrayWriter* writer) {
2268 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