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

Function WriteTableToBuffer

cpp/src/parquet/chunker_internal_test.cc:340–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340Result<std::shared_ptr<Buffer>> WriteTableToBuffer(
341 const std::shared_ptr<Table>& table, int64_t min_chunk_size, int64_t max_chunk_size,
342 int64_t row_group_length = 1024 * 1024, bool enable_dictionary = false,
343 ParquetDataPageVersion data_page_version = ParquetDataPageVersion::V1) {
344 auto sink = CreateOutputStream();
345
346 auto builder = WriterProperties::Builder();
347 builder.enable_content_defined_chunking()->content_defined_chunking_options(
348 {min_chunk_size, max_chunk_size, /*norm_level=*/0});
349 builder.data_page_version(data_page_version);
350 if (enable_dictionary) {
351 builder.enable_dictionary();
352 } else {
353 builder.disable_dictionary();
354 }
355 auto write_props = builder.build();
356 auto arrow_props = ArrowWriterProperties::Builder().store_schema()->build();
357 RETURN_NOT_OK(WriteTable(*table, default_memory_pool(), sink, row_group_length,
358 write_props, arrow_props));
359 ARROW_ASSIGN_OR_RAISE(auto buffer, sink->Finish());
360
361 // validate that the data correctly roundtrips
362 ARROW_ASSIGN_OR_RAISE(auto readback, ReadTableFromBuffer(buffer));
363 RETURN_NOT_OK(readback->ValidateFull());
364 ARROW_RETURN_IF(!readback->Equals(*table),
365 Status::Invalid("Readback table not equal to original"));
366
367 return buffer;
368}
369
370// Type to represent a list of chunks where each element is the size of the chunk.
371using ChunkList = std::vector<int64_t>;

Callers

nothing calls this directly

Calls 9

CreateOutputStreamFunction · 0.85
default_memory_poolFunction · 0.85
store_schemaMethod · 0.80
BuilderFunction · 0.70
WriteTableFunction · 0.50
InvalidFunction · 0.50
buildMethod · 0.45
ValidateFullMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected