Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ccat3z committed Nov 18, 2024
1 parent 8eea3c7 commit 2203599
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 1 addition & 5 deletions cpp/core/shuffle/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,7 @@ arrow::Result<std::shared_ptr<MmapFileStream>> MmapFileStream::open(const std::s
return arrow::Status::IOError("Memory mapping file failed: ", ::arrow::internal::ErrnoMessage(errno));
}

auto fstream = std::shared_ptr<MmapFileStream>(new MmapFileStream());
fstream->fd_ = std::move(fd);
fstream->data_ = static_cast<uint8_t*>(result);
fstream->size_ = size;
return fstream;
return std::make_shared<MmapFileStream>(std::move(fd), static_cast<uint8_t*>(result), size);
}

void MmapFileStream::advance(int64_t length) {
Expand Down
5 changes: 4 additions & 1 deletion cpp/core/shuffle/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ arrow::Result<std::shared_ptr<arrow::RecordBatch>> makeUncompressedRecordBatch(

std::shared_ptr<arrow::Buffer> zeroLengthNullBuffer();

// MmapFileStream is used to optimize sequential file reading. It uses madvise
// to prefetch and release memory timely.
class MmapFileStream : public arrow::io::InputStream {
public:
MmapFileStream(arrow::internal::FileDescriptor fd, uint8_t* data, int64_t size)
: fd_(std::move(fd)), data_(data), size_(size){};
static arrow::Result<std::shared_ptr<MmapFileStream>> open(const std::string& path);
arrow::Result<int64_t> Tell() const override;
arrow::Status Close() override;
Expand All @@ -99,7 +103,6 @@ class MmapFileStream : public arrow::io::InputStream {
int64_t size_;
int64_t pos_ = 0;
int64_t posRetain_ = 0;
MmapFileStream() = default;
};

} // namespace gluten

0 comments on commit 2203599

Please sign in to comment.