From d860fd5ba80f0d6f5716bd8b7aae46e1ee1ddc18 Mon Sep 17 00:00:00 2001 From: zzzxl1993 <474696115@qq.com> Date: Thu, 21 Mar 2024 15:25:24 +0800 Subject: [PATCH] [fix](inverted index) add the inverted index to the file cache --- .../segment_v2/inverted_index_compound_directory.cpp | 10 ++++++++-- .../segment_v2/inverted_index_compound_directory.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp index e7f8f6abe26d62..6e5ea6da457dab 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp @@ -257,7 +257,12 @@ bool DorisCompoundDirectory::FSIndexInput::open(const io::FileSystemSPtr& fs, co } auto* h = _CLNEW SharedHandle(path); - if (!fs->open_file(path, &h->_reader).ok()) { + io::FileDescription fd; + fd.path = path; + io::FileBlockCachePathPolicy cache_policy; + auto type = config::enable_file_cache ? config::file_cache_type : ""; + io::FileReaderOptions reader_options(io::cache_type_from_string(type), cache_policy); + if (!fs->open_file(fd, reader_options, &h->_reader).ok()) { error.set(CL_ERR_IO, "open file error"); } @@ -295,6 +300,7 @@ DorisCompoundDirectory::FSIndexInput::FSIndexInput(const FSIndexInput& other) std::lock_guard wlock(*other._handle->_shared_lock); _handle = _CL_POINTER(other._handle); _pos = other._handle->_fpos; //note where we are currently... + _io_ctx = other._io_ctx; } DorisCompoundDirectory::FSIndexInput::SharedHandle::SharedHandle(const char* path) { @@ -361,7 +367,7 @@ void DorisCompoundDirectory::FSIndexInput::readInternal(uint8_t* b, const int32_ Slice result {b, (size_t)len}; size_t bytes_read = 0; - if (!_handle->_reader->read_at(_pos, result, &bytes_read).ok()) { + if (!_handle->_reader->read_at(_pos, result, &bytes_read, &_io_ctx).ok()) { _CLTHROWA(CL_ERR_IO, "read past EOF"); } bufferLength = len; diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.h b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.h index 94f8b3ccc79eb3..d9fd6146bbd545 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.h +++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.h @@ -186,10 +186,12 @@ class DorisCompoundDirectory::FSIndexInput : public lucene::store::BufferedIndex SharedHandle* _handle = nullptr; int64_t _pos; + io::IOContext _io_ctx; FSIndexInput(SharedHandle* handle, int32_t buffer_size) : BufferedIndexInput(buffer_size) { this->_pos = 0; this->_handle = handle; + this->_io_ctx.reader_type = ReaderType::READER_QUERY; } protected: