mogui commented on a change in pull request #679:
URL: https://github.com/apache/lucene/pull/679#discussion_r809076507



##########
File path: 
lucene/monitor/src/java/org/apache/lucene/monitor/ReadonlyQueryIndex.java
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.lucene.monitor;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.*;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.IOUtils;
+
+class ReadonlyQueryIndex implements QueryIndex {
+  private final SearcherManager manager;
+  private final QueryDecomposer decomposer;
+  private final MonitorQuerySerializer serializer;
+
+  final Map<IndexReader.CacheKey, WritableQueryIndex.QueryTermFilter> 
termFilters = new HashMap<>();
+
+  public ReadonlyQueryIndex(MonitorConfiguration configuration) throws 
IOException {
+    if (configuration.getDirectoryProvider() == null) {
+      throw new IllegalStateException(
+          "You must specify a Directory when configuring a Monitor as 
read-only.");
+    }
+    Directory directory = configuration.getDirectoryProvider().get();
+    this.manager = new SearcherManager(directory, new 
TermsHashBuilder(termFilters));
+    this.decomposer = configuration.getQueryDecomposer();
+    this.serializer = configuration.getQuerySerializer();

Review comment:
       What do you think if I keep all the in-memory cache things along with 
the purgeExecutor in the abstract QueryIndex class and let the readonly monitor 
use it too, closing this round of improvements.
   Then open another changeset to implement the lazy parsing.
   




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to