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

Function WriteTableToBuffer

cpp/src/parquet/chunker_internal_test.cc:335–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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