Mimic the Parquet reader, reading the file in small chunks.
| 228 | |
| 229 | /// Mimic the Parquet reader, reading the file in small chunks. |
| 230 | static 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. |
| 255 | static void CoalescedRead(benchmark::State& st, S3FileSystem* fs, |
no test coverage detected