lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [24/44] lucene-solr:jira/solr-12709: LUCENE-8459: add SearcherTaxonomyManager constructor taking already opened readers
Date Mon, 17 Sep 2018 10:09:09 GMT
LUCENE-8459: add SearcherTaxonomyManager constructor taking already opened readers


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a9551404
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a9551404
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a9551404

Branch: refs/heads/jira/solr-12709
Commit: a9551404fd057c83abe3b47bbf9124d335790cbe
Parents: 89bc082
Author: Mike McCandless <mikemccand@apache.org>
Authored: Tue Sep 11 14:57:43 2018 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Tue Sep 11 14:57:43 2018 -0400

----------------------------------------------------------------------
 lucene/CHANGES.txt                                    |  4 ++++
 .../facet/taxonomy/SearcherTaxonomyManager.java       | 14 ++++++++++++++
 .../facet/taxonomy/TestSearcherTaxonomyManager.java   | 14 ++++++++++++++
 3 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a9551404/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a9b97a7..5035625 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -219,6 +219,10 @@ API Changes:
 * LUCENE-8422: Static helper functions for Matches and MatchesIterator implementations
   have been moved from Matches to MatchesUtils (Alan Woodward)
 
+* LUCENE-8459: SearcherTaxonomyManager now has a constructor taking already opened
+  IndexReaders, allowing the caller to pass a FilterDirectoryReader, for example.
+  (Mike McCandless)
+
 Bug Fixes:
 
 * LUCENE-8445: Tighten condition when two planes are identical to prevent constructing

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a9551404/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
index e618aa5..82fd2dd 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
@@ -98,6 +98,20 @@ public class SearcherTaxonomyManager extends ReferenceManager<SearcherTaxonomyMa
     taxoEpoch = -1;
   }
 
+  /**
+   * Creates this from already opened {@link IndexReader} and {@link DirectoryTaxonomyReader}
instances.  Note that
+   * the incoming readers will be closed when you call {@link #close}.
+   */
+  public SearcherTaxonomyManager(IndexReader reader, DirectoryTaxonomyReader taxoReader,
SearcherFactory searcherFactory) throws IOException {
+    if (searcherFactory == null) {
+      searcherFactory = new SearcherFactory();
+    }
+    this.searcherFactory = searcherFactory;
+    current = new SearcherAndTaxonomy(SearcherManager.getSearcher(searcherFactory, reader,
null), taxoReader);
+    this.taxoWriter = null;
+    taxoEpoch = -1;
+  }
+
   @Override
   protected void decRef(SearcherAndTaxonomy ref) throws IOException {
     ref.searcher.getIndexReader().decRef();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a9551404/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
index d9a3f8e..e8c764e 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
@@ -32,14 +32,18 @@ import org.apache.lucene.facet.Facets;
 import org.apache.lucene.facet.FacetsCollector;
 import org.apache.lucene.facet.FacetsConfig;
 import org.apache.lucene.facet.taxonomy.SearcherTaxonomyManager.SearcherAndTaxonomy;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexNotFoundException;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.SegmentInfos;
 import org.apache.lucene.index.TieredMergePolicy;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.ReferenceManager;
+import org.apache.lucene.search.SearcherFactory;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.TestUtil;
@@ -347,4 +351,14 @@ public class TestSearcherTaxonomyManager extends FacetTestCase {
     expectThrows(IndexNotFoundException.class, mgr::maybeRefreshBlocking);
     IOUtils.close(w, tw, mgr, indexDir, taxoDir);
   }
+
+  private SearcherTaxonomyManager getSearcherTaxonomyManager(Directory indexDir, Directory
taxoDir, SearcherFactory searcherFactory) throws IOException {
+    if (random().nextBoolean()) {
+      return new SearcherTaxonomyManager(indexDir, taxoDir, searcherFactory);
+    } else {
+      IndexReader reader = DirectoryReader.open(indexDir);
+      DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
+      return new SearcherTaxonomyManager(reader, taxoReader, searcherFactory);
+    }
+  }
 }


Mime
View raw message