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

Function ChunkedRead

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

Mimic the Parquet reader, reading the file in small chunks.

Source from the content-addressed store, hash-verified

228
229/// Mimic the Parquet reader, reading the file in small chunks.
230static void ChunkedRead(benchmark::State& st, S3FileSystem* fs, const std::string& path) {
231 int64_t total_bytes = 0;
232 int total_items = 0;
233 for (auto _ : st) {
234 std::shared_ptr<io::RandomAccessFile> file;
235 std::shared_ptr<Buffer> buf;
236 int64_t size = 0;
237 ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile(path));
238 ASSERT_OK_AND_ASSIGN(size, file->GetSize());
239 total_items += 1;
240
241 int64_t offset = 0;
242 while (offset < size) {
243 const int64_t read = std::min(size, kChunkSize);
244 ASSERT_OK_AND_ASSIGN(buf, file->ReadAt(offset, read));
245 total_bytes += buf->size();
246 offset += buf->size();
247 }
248 }
249 st.SetBytesProcessed(total_bytes);
250 st.SetItemsProcessed(total_items);
251 std::cerr << "Read the file " << total_items << " times" << std::endl;
252}
253
254/// Read the file in small chunks, but using read coalescing.
255static void CoalescedRead(benchmark::State& st, S3FileSystem* fs,

Calls 5

ASSERT_OK_AND_ASSIGNFunction · 0.70
OpenInputFileMethod · 0.45
GetSizeMethod · 0.45
ReadAtMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected