bhabegger commented on code in PR #2817:
URL: https://github.com/apache/jackrabbit-oak/pull/2817#discussion_r3861635269


##########
oak-search-lucene-ng/src/main/java/org/apache/jackrabbit/oak/plugins/index/luceneNg/internal/IndexSearcherHolder.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.luceneNg.internal;
+
+import org.apache.jackrabbit.oak.plugins.index.luceneNg.LuceneNgIndexStorage;
+import org.apache.jackrabbit.oak.plugins.index.luceneNg.directory.OakDirectory;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.search.IndexSearcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Manages IndexSearcher lifecycle for a Lucene 9 index.
+ * Opens the index from the {@link LuceneNgIndexStorage} node state passed in 
(typically the
+ * {@link LuceneNgIndexStorage#STORAGE_NODE_NAME} child under the index 
definition).
+ */
+public class IndexSearcherHolder implements Closeable {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(IndexSearcherHolder.class);
+
+    private final String indexName;
+    private DirectoryReader reader;
+    private IndexSearcher searcher;
+    private OakDirectory directory;
+    private final ConcurrentMap<String, DefaultSortedSetDocValuesReaderState> 
facetStateCache =
+            new ConcurrentHashMap<>();
+
+    /**
+     * @param storageState {@link 
LuceneNgIndexStorage#storageState(NodeState)} for the index definition
+     * @param indexName    the index name, used only for logging/error messages
+     */
+
+    public IndexSearcherHolder(NodeState storageState, String indexName) 
throws IOException {
+        this.indexName = indexName;
+        this.directory = new OakDirectory(storageState.builder(), indexName, 
true);

Review Comment:
   > Also, adding this with the extended common oak-search extension might have 
some quirks (new overloaded methods etc) which might be cleaner in a new impl 
as this.
   
   I'm not sure what you meant exactly by this. If it is to generalize and 
simplify the code, I'm all in. Just note that, this PR was voluntarily built in 
a way to keep running production code not using this feature completely 
untouched. (Notice only tests have been adjusted to validate feature 
iso-behavior).



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