lxy-9602 commented on code in PR #483:
URL: https://github.com/apache/paimon-cpp/pull/483#discussion_r4548989775


##########
src/paimon/core/io/file_index_evaluator.cpp:
##########
@@ -126,6 +138,29 @@ Result<std::shared_ptr<FileIndexReader>> 
FileIndexEvaluator::GetSearchReader(
         return Status::Invalid(fmt::format("Data file '{}' has no File Index 
for search field '{}'",
                                            file_meta_->file_name, field_name));
     }
+    std::vector<std::string> index_types;
+    if (cache_ && !uri_.empty() && search_type == 
FileIndexReader::SearchType::VECTOR_SEARCH) {
+        index_types = format_reader_->GetIndexTypes(field_name);
+    }
+    // Multiple index types must go through the normal reader selection and 
validation.
+    if (index_types.size() == 1) {
+        auto key = CacheKey::ForIndexReader(uri_, field_name, 
index_types.front());
+        // An error from the supplier prevents insertion, including a null 
cache entry.
+        auto value = cache_->Get(
+            key, [](const std::shared_ptr<CacheKey>&) -> 
Result<std::shared_ptr<CacheValue>> {
+                return Status::NotExist("Vector index reader is not cached");
+            });
+        if (!value.ok() && !value.status().IsNotExist()) {
+            return value.status();
+        }
+        if (value.ok() && value.value()) {
+            auto reader = CacheValue::Get<FileIndexReader>(value.value());
+            if (!reader) {
+                return Status::Invalid("Vector index reader cache returned an 
invalid value");
+            }
+            return reader;

Review Comment:
   Suggest checking `SupportsSearch(search_type)` even when the cache hits.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to