bhabegger commented on code in PR #2817: URL: https://github.com/apache/jackrabbit-oak/pull/2817#discussion_r3845134056
########## 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: I heard a lot about NRT being mostly abused and I think we could have a first go without it. I would like to test an already big change. Let's make sure everything works without NRT and then add it back in a second step. -- 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]
