| 134 | class SizeStatisticsRoundTripTest : public ::testing::Test { |
| 135 | public: |
| 136 | void WriteFile(SizeStatisticsLevel level, const std::shared_ptr<::arrow::Table>& table, |
| 137 | int max_row_group_length, int page_size, |
| 138 | int write_batch_size = DEFAULT_WRITE_BATCH_SIZE) { |
| 139 | auto writer_properties = WriterProperties::Builder() |
| 140 | .max_row_group_length(max_row_group_length) |
| 141 | ->data_pagesize(page_size) |
| 142 | ->max_rows_per_page(std::numeric_limits<int64_t>::max()) |
| 143 | ->write_batch_size(write_batch_size) |
| 144 | ->enable_write_page_index() |
| 145 | ->enable_statistics() |
| 146 | ->set_size_statistics_level(level) |
| 147 | ->build(); |
| 148 | |
| 149 | // Get schema from table. |
| 150 | auto schema = table->schema(); |
| 151 | std::shared_ptr<SchemaDescriptor> parquet_schema; |
| 152 | auto arrow_writer_properties = default_arrow_writer_properties(); |
| 153 | ASSERT_OK_NO_THROW(arrow::ToParquetSchema(schema.get(), *writer_properties, |
| 154 | *arrow_writer_properties, &parquet_schema)); |
| 155 | auto schema_node = |
| 156 | std::static_pointer_cast<schema::GroupNode>(parquet_schema->schema_root()); |
| 157 | |
| 158 | // Write table to buffer. |
| 159 | auto sink = CreateOutputStream(); |
| 160 | auto pool = ::arrow::default_memory_pool(); |
| 161 | auto writer = ParquetFileWriter::Open(sink, schema_node, writer_properties); |
| 162 | std::unique_ptr<arrow::FileWriter> arrow_writer; |
| 163 | ASSERT_OK(arrow::FileWriter::Make(pool, std::move(writer), schema, |
| 164 | arrow_writer_properties, &arrow_writer)); |
| 165 | ASSERT_OK_NO_THROW(arrow_writer->WriteTable(*table)); |
| 166 | ASSERT_OK_NO_THROW(arrow_writer->Close()); |
| 167 | ASSERT_OK_AND_ASSIGN(buffer_, sink->Finish()); |
| 168 | } |
| 169 | |
| 170 | void ReadSizeStatistics() { |
| 171 | auto read_properties = default_arrow_reader_properties(); |
nothing calls this directly
no test coverage detected