MCPcopy Create free account
hub / github.com/bytedance/bolt / SpillReadFileBase

Method SpillReadFileBase

bolt/exec/SpillFile.cpp:591–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589}
590
591SpillReadFileBase::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
632bool SpillReadFile::nextBatch(RowVectorPtr& rowVector) {
633 if (input_->atEnd()) {

Callers

nothing calls this directly

Calls 7

getNamedVectorSerdeFunction · 0.85
getFileSystemFunction · 0.85
has_valueMethod · 0.80
openAsyncFileForReadMethod · 0.45
openFileForReadMethod · 0.45
uringEnabledMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected