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

Function ParquetRead

cpp/src/arrow/filesystem/s3fs_benchmark.cc:295–331  ·  view source on GitHub ↗

Read a Parquet file from S3.

Source from the content-addressed store, hash-verified

293
294/// Read a Parquet file from S3.
295static 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.
334static void ParquetReadAll(benchmark::State& st, S3FileSystem* fs,

Callers 2

ParquetReadAllFunction · 0.85
ParquetReadSomeFunction · 0.85

Calls 9

ASSERT_OK_AND_ASSIGNFunction · 0.70
set_use_threadsMethod · 0.45
OpenInputFileMethod · 0.45
GetSizeMethod · 0.45
OpenMethod · 0.45
BuildMethod · 0.45
propertiesMethod · 0.45
ToTableMethod · 0.45

Tested by

no test coverage detected