| 333 | } |
| 334 | |
| 335 | Result<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. |
| 366 | using ChunkList = std::vector<int64_t>; |
nothing calls this directly
no test coverage detected