airborne12 commented on code in PR #43992:
URL: https://github.com/apache/doris/pull/43992#discussion_r1942397400


##########
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:
   Yes, the newly created index file must not already be in the cache; 
otherwise, we cannot be sure if it is correct, so we delete it and add a new 
one instead.



-- 
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

Reply via email to