| 589 | } |
| 590 | |
| 591 | SpillReadFileBase::SpillReadFileBase( |
| 592 | const SpillFileInfo& fileInfo, |
| 593 | memory::MemoryPool* pool, |
| 594 | const bool spillUringEnabled) |
| 595 | : id_(fileInfo.id), |
| 596 | path_(fileInfo.path), |
| 597 | size_(fileInfo.size), |
| 598 | type_(fileInfo.type), |
| 599 | sortingKeys_(fileInfo.sortingKeys), |
| 600 | compressionKind_(fileInfo.compressionKind), |
| 601 | readOptions_{kDefaultUseLosslessTimestamp, compressionKind_}, |
| 602 | serdeKind_(fileInfo.serdeKind), |
| 603 | serde_( |
| 604 | serdeKind_.has_value() ? getNamedVectorSerde(*serdeKind_) : nullptr), |
| 605 | spillUringEnabled_(spillUringEnabled), |
| 606 | pool_(pool) { |
| 607 | constexpr uint64_t kMaxReadBufferSize = |
| 608 | (1 << 20) - AlignedBuffer::kPaddedSize; // 1MB - padding. |
| 609 | auto fs = filesystems::getFileSystem(path_, nullptr); |
| 610 | std::unique_ptr<ReadFile> file; |
| 611 | #ifdef IO_URING_SUPPORTED |
| 612 | file = spillUringEnabled_ ? fs->openAsyncFileForRead(path_) |
| 613 | : fs->openFileForRead(path_); |
| 614 | #else |
| 615 | file = fs->openFileForRead(path_); |
| 616 | #endif |
| 617 | |
| 618 | // For io_uring enabled spill read, maintain two read buffers, one for storing |
| 619 | // current batch, one for prefetching. If io_uring is disabled or fails to |
| 620 | // init, just use one buffer for blocking pread. |
| 621 | int bufferLength = (spillUringEnabled && file->uringEnabled()) ? 2 : 1; |
| 622 | std::vector<BufferPtr> readBuffers; |
| 623 | readBuffers.resize(bufferLength); |
| 624 | for (int i = 0; i < bufferLength; i++) { |
| 625 | readBuffers[i] = AlignedBuffer::allocate<char>(kMaxReadBufferSize, pool_); |
| 626 | } |
| 627 | |
| 628 | input_ = std::make_unique<SpillInputStream>( |
| 629 | std::move(file), readBuffers, spillUringEnabled); |
| 630 | } |
| 631 | |
| 632 | bool SpillReadFile::nextBatch(RowVectorPtr& rowVector) { |
| 633 | if (input_->atEnd()) { |
nothing calls this directly
no test coverage detected