Read a Parquet file from S3.
| 293 | |
| 294 | /// Read a Parquet file from S3. |
| 295 | static void ParquetRead(benchmark::State& st, S3FileSystem* fs, const std::string& path, |
| 296 | std::vector<int> column_indices, bool pre_buffer, |
| 297 | std::string read_strategy) { |
| 298 | int64_t total_bytes = 0; |
| 299 | int total_items = 0; |
| 300 | |
| 301 | parquet::ArrowReaderProperties properties; |
| 302 | properties.set_use_threads(true); |
| 303 | properties.set_pre_buffer(pre_buffer); |
| 304 | parquet::ReaderProperties parquet_properties = parquet::default_reader_properties(); |
| 305 | |
| 306 | for (auto _ : st) { |
| 307 | std::shared_ptr<io::RandomAccessFile> file; |
| 308 | int64_t size = 0; |
| 309 | ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile(path)); |
| 310 | ASSERT_OK_AND_ASSIGN(size, file->GetSize()); |
| 311 | |
| 312 | std::unique_ptr<parquet::arrow::FileReader> reader; |
| 313 | parquet::arrow::FileReaderBuilder builder; |
| 314 | ASSERT_OK(builder.Open(file, parquet_properties)); |
| 315 | ASSERT_OK(builder.properties(properties)->Build(&reader)); |
| 316 | |
| 317 | if (read_strategy == "ReadTable") { |
| 318 | ASSERT_OK_AND_ASSIGN(auto table, reader->ReadTable(column_indices)); |
| 319 | } else { |
| 320 | ASSERT_OK_AND_ASSIGN(auto rb_reader, reader->GetRecordBatchReader( |
| 321 | std::vector<int>{0}, column_indices)); |
| 322 | ASSERT_OK(rb_reader->ToTable()); |
| 323 | } |
| 324 | |
| 325 | // TODO: actually measure table memory usage |
| 326 | total_bytes += size; |
| 327 | total_items += 1; |
| 328 | } |
| 329 | st.SetBytesProcessed(total_bytes); |
| 330 | st.SetItemsProcessed(total_items); |
| 331 | } |
| 332 | |
| 333 | /// Helper function used in the macros below to template benchmarks. |
| 334 | static void ParquetReadAll(benchmark::State& st, S3FileSystem* fs, |
no test coverage detected