diff --git a/velox/common/file/File.h b/velox/common/file/File.h index 32f8540eb3acc..53128c3dbe834 100644 --- a/velox/common/file/File.h +++ b/velox/common/file/File.h @@ -251,7 +251,7 @@ struct HeapMemoryMock { size_ += len; } - void read(void* dst, size_ len, size_t offset) { + void read(void* dst, size_t len, size_t offset) { assert(offset + len <= size_); memcpy(dst, (char*)memory_ + offset, len); } diff --git a/velox/exec/Spill.cpp b/velox/exec/Spill.cpp index 926cac340cf3c..76cb1af58bf12 100644 --- a/velox/exec/Spill.cpp +++ b/velox/exec/Spill.cpp @@ -77,12 +77,13 @@ void SpillFile::startRead() { auto buffer = AlignedBuffer::allocate( std::min(fileSize_, kMaxReadBufferSize), &pool_); input_ = std::make_unique(std::move(file), std::move(buffer)); - } else { - std::unique_ptr = - std::make_unique(heapMemoryMock_); + } else if (toWhere_ == TO_HEAP) { + auto file = std::make_unique(heapMemoryMock_); auto buffer = AlignedBuffer::allocate( std::min(fileSize_, kMaxReadBufferSize), &pool_); input_ = std::make_unique(std::move(file), std::move(buffer)); + } else { + VELOX_FAIL("invalid spill destination"); } }