xiaokang commented on code in PR #43992: URL: https://github.com/apache/doris/pull/43992#discussion_r1942299912
########## be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp: ########## @@ -120,6 +123,62 @@ int64_t InvertedIndexFileWriter::headerLength() { return header_size; } +Status InvertedIndexFileWriter::add_into_searcher_cache() { + auto inverted_index_file_reader = + std::make_unique<InvertedIndexFileReader>(_fs, _index_path_prefix, _storage_format); + auto st = inverted_index_file_reader->init(); + if (!st.ok()) { + if (dynamic_cast<io::StreamSinkFileWriter*>(_idx_v2_writer.get()) != nullptr) { + //StreamSinkFileWriter not found file is normal. + return Status::OK(); + } + LOG(WARNING) << "InvertedIndexFileWriter::add_into_searcher_cache for " + << _index_path_prefix << ", error " << st.msg(); + return st; + } + for (const auto& entry : _indices_dirs) { + auto index_meta = entry.first; + auto dir = + DORIS_TRY(inverted_index_file_reader->_open(index_meta.first, index_meta.second)); + auto index_file_key = InvertedIndexDescriptor::get_index_file_cache_key( + _index_path_prefix, index_meta.first, index_meta.second); + InvertedIndexSearcherCache::CacheKey searcher_cache_key(index_file_key); + InvertedIndexCacheHandle inverted_index_cache_handle; + if (InvertedIndexSearcherCache::instance()->lookup(searcher_cache_key, + &inverted_index_cache_handle)) { + auto st = InvertedIndexSearcherCache::instance()->erase( Review Comment: Delete it if it already in cache? ########## be/src/olap/rowset/segment_v2/inverted_index_reader.cpp: ########## @@ -234,13 +237,9 @@ Status InvertedIndexReader::handle_searcher_cache( } } -Status InvertedIndexReader::create_index_searcher(lucene::store::Directory* dir, - IndexSearcherPtr* searcher, - InvertedIndexReaderType reader_type, - size_t& reader_size) { - auto index_searcher_builder = Review Comment: Why move it outside of create_index_searcher? ########## be/src/olap/rowset/segment_v2/inverted_index_file_writer.cpp: ########## @@ -120,6 +123,62 @@ int64_t InvertedIndexFileWriter::headerLength() { return header_size; } +Status InvertedIndexFileWriter::add_into_searcher_cache() { + auto inverted_index_file_reader = + std::make_unique<InvertedIndexFileReader>(_fs, _index_path_prefix, _storage_format); + auto st = inverted_index_file_reader->init(); + if (!st.ok()) { + if (dynamic_cast<io::StreamSinkFileWriter*>(_idx_v2_writer.get()) != nullptr) { + //StreamSinkFileWriter not found file is normal. + return Status::OK(); + } + LOG(WARNING) << "InvertedIndexFileWriter::add_into_searcher_cache for " + << _index_path_prefix << ", error " << st.msg(); + return st; + } + for (const auto& entry : _indices_dirs) { + auto index_meta = entry.first; + auto dir = Review Comment: The code in for loop is almost the same as `InvertedIndexReader::handle_searcher_cache`. Can you refactor `InvertedIndexReader::handle_searcher_cache` and call it here? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org