mirror of https://github.com/apache/lucene.git
LUCENE-3552: rename LuceneTaxonomyReader/Writer to DirectoryTaxonomyReader/Writer
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1196963 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd9606a8b1
commit
52ab4cb9a8
|
@ -18,7 +18,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -37,7 +37,7 @@ public class CreateTaxonomyIndexTask extends PerfTask {
|
|||
@Override
|
||||
public int doLogic() throws IOException {
|
||||
PerfRunData runData = getRunData();
|
||||
runData.setTaxonomyWriter(new LuceneTaxonomyWriter(runData.getTaxonomyDir(), OpenMode.CREATE));
|
||||
runData.setTaxonomyWriter(new DirectoryTaxonomyWriter(runData.getTaxonomyDir(), OpenMode.CREATE));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class OpenTaxonomyIndexTask extends PerfTask {
|
|||
@Override
|
||||
public int doLogic() throws IOException {
|
||||
PerfRunData runData = getRunData();
|
||||
runData.setTaxonomyWriter(new LuceneTaxonomyWriter(runData.getTaxonomyDir()));
|
||||
runData.setTaxonomyWriter(new DirectoryTaxonomyWriter(runData.getTaxonomyDir()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Open a taxonomy index reader.
|
||||
|
@ -35,7 +35,7 @@ public class OpenTaxonomyReaderTask extends PerfTask {
|
|||
@Override
|
||||
public int doLogic() throws IOException {
|
||||
PerfRunData runData = getRunData();
|
||||
LuceneTaxonomyReader taxoReader = new LuceneTaxonomyReader(runData.getTaxonomyDir());
|
||||
DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(runData.getTaxonomyDir());
|
||||
runData.setTaxonomyReader(taxoReader);
|
||||
// We transfer reference to the run data
|
||||
taxoReader.decRef();
|
||||
|
|
|
@ -264,7 +264,7 @@ Following is a code snippet for indexing categories. The complete example can be
|
|||
found in package <code>org.apache.lucene.facet.example.simple.SimpleIndexer</code>.
|
||||
<pre class="prettyprint lang-java linenums">
|
||||
IndexWriter writer = ...
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
...
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("title", titleText, Store.YES, Index.ANALYZED));
|
||||
|
@ -366,7 +366,7 @@ found under <code>org.apache.lucene.facet.example.simple.Searcher</code>:
|
|||
<pre class="prettyprint lang-java linenums">
|
||||
IndexReader indexReader = IndexReader.open(indexDir);
|
||||
Searcher searcher = new IndexSearcher(indexReader);
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
...
|
||||
Query q = new TermQuery(new Term(SimpleUtils.TEXT, "white"));
|
||||
TopScoreDocCollector tdc = TopScoreDocCollector.create(10, true);
|
||||
|
@ -781,4 +781,4 @@ the only thing that can happen is that new categories are added. Since search th
|
|||
are added in the middle of a search, there is no reason to keep around the old object, and the new one suffices.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ExampleUtils {
|
|||
public static final boolean VERBOSE = Boolean.getBoolean("tests.verbose");
|
||||
|
||||
/** The Lucene {@link Version} used by the example code. */
|
||||
public static final Version EXAMPLE_VER = Version.LUCENE_31;
|
||||
public static final Version EXAMPLE_VER = Version.LUCENE_40;
|
||||
|
||||
public static void log(Object msg) {
|
||||
if (VERBOSE) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.lucene.facet.search.params.FacetSearchParams;
|
|||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -55,7 +55,7 @@ public class AdaptiveSearcher {
|
|||
*/
|
||||
public static List<FacetResult> searchWithFacets (Directory indexDir, Directory taxoDir) throws Exception {
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
IndexReader indexReader = IndexReader.open(indexDir);
|
||||
|
||||
// prepare searcher to search against
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.apache.lucene.facet.index.CategoryContainer;
|
|||
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -60,7 +60,7 @@ public class AssociationIndexer {
|
|||
IndexWriter iw = new IndexWriter(indexDir, new IndexWriterConfig(ExampleUtils.EXAMPLE_VER, SimpleUtils.analyzer));
|
||||
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
|
||||
// loop over sample documents
|
||||
int nDocsAdded = 0;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.apache.lucene.facet.search.params.association.AssociationIntSumFacetR
|
|||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -43,7 +43,7 @@ public class AssociationSearcher {
|
|||
Directory taxoDir) throws Exception {
|
||||
// prepare index reader
|
||||
IndexReader indexReader = IndexReader.open(indexDir);
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
AssociationIntSumFacetRequest facetRequest = new AssociationIntSumFacetRequest(
|
||||
new CategoryPath("tags"), 10);
|
||||
|
@ -63,7 +63,7 @@ public class AssociationSearcher {
|
|||
Directory taxoDir) throws Exception {
|
||||
// prepare index reader
|
||||
IndexReader indexReader = IndexReader.open(indexDir);
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
AssociationFloatSumFacetRequest facetRequest = new AssociationFloatSumFacetRequest(
|
||||
new CategoryPath("genre"), 10);
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.facet.example.ExampleUtils;
|
||||
import org.apache.lucene.facet.index.FacetsPayloadProcessorProvider;
|
||||
import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.DiskOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.MemoryOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.OrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.DiskOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.MemoryOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -40,19 +40,19 @@ public class TaxonomyMergeUtils {
|
|||
|
||||
/**
|
||||
* Merges the given taxonomy and index directories. Note that this method
|
||||
* opens {@link LuceneTaxonomyWriter} and {@link IndexWriter} on the
|
||||
* opens {@link DirectoryTaxonomyWriter} and {@link IndexWriter} on the
|
||||
* respective destination indexes. Therefore if you have a writer open on any
|
||||
* of them, it should be closed, or you should use
|
||||
* {@link #merge(Directory, Directory, IndexWriter, LuceneTaxonomyWriter)}
|
||||
* {@link #merge(Directory, Directory, IndexWriter, DirectoryTaxonomyWriter)}
|
||||
* instead.
|
||||
*
|
||||
* @see #merge(Directory, Directory, IndexWriter, LuceneTaxonomyWriter)
|
||||
* @see #merge(Directory, Directory, IndexWriter, DirectoryTaxonomyWriter)
|
||||
*/
|
||||
public static void merge(Directory srcIndexDir, Directory srcTaxDir,
|
||||
Directory destIndexDir, Directory destTaxDir) throws IOException {
|
||||
IndexWriter destIndexWriter = new IndexWriter(destIndexDir,
|
||||
new IndexWriterConfig(ExampleUtils.EXAMPLE_VER, null));
|
||||
LuceneTaxonomyWriter destTaxWriter = new LuceneTaxonomyWriter(destTaxDir);
|
||||
DirectoryTaxonomyWriter destTaxWriter = new DirectoryTaxonomyWriter(destTaxDir);
|
||||
merge(srcIndexDir, srcTaxDir, new MemoryOrdinalMap(), destIndexWriter, destTaxWriter);
|
||||
destTaxWriter.close();
|
||||
destIndexWriter.close();
|
||||
|
@ -62,14 +62,14 @@ public class TaxonomyMergeUtils {
|
|||
* Merges the given taxonomy and index directories and commits the changes to
|
||||
* the given writers. This method uses {@link MemoryOrdinalMap} to store the
|
||||
* mapped ordinals. If you cannot afford the memory, you can use
|
||||
* {@link #merge(Directory, Directory, LuceneTaxonomyWriter.OrdinalMap, IndexWriter, LuceneTaxonomyWriter)}
|
||||
* {@link #merge(Directory, Directory, DirectoryTaxonomyWriter.OrdinalMap, IndexWriter, DirectoryTaxonomyWriter)}
|
||||
* by passing {@link DiskOrdinalMap}.
|
||||
*
|
||||
* @see #merge(Directory, Directory, LuceneTaxonomyWriter.OrdinalMap, IndexWriter, LuceneTaxonomyWriter)
|
||||
* @see #merge(Directory, Directory, DirectoryTaxonomyWriter.OrdinalMap, IndexWriter, DirectoryTaxonomyWriter)
|
||||
*/
|
||||
public static void merge(Directory srcIndexDir, Directory srcTaxDir,
|
||||
IndexWriter destIndexWriter,
|
||||
LuceneTaxonomyWriter destTaxWriter) throws IOException {
|
||||
DirectoryTaxonomyWriter destTaxWriter) throws IOException {
|
||||
merge(srcIndexDir, srcTaxDir, new MemoryOrdinalMap(), destIndexWriter, destTaxWriter);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class TaxonomyMergeUtils {
|
|||
*/
|
||||
public static void merge(Directory srcIndexDir, Directory srcTaxDir,
|
||||
OrdinalMap map, IndexWriter destIndexWriter,
|
||||
LuceneTaxonomyWriter destTaxWriter) throws IOException {
|
||||
DirectoryTaxonomyWriter destTaxWriter) throws IOException {
|
||||
// merge the taxonomies
|
||||
destTaxWriter.addTaxonomies(new Directory[] { srcTaxDir }, new OrdinalMap[] { map });
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.lucene.facet.index.params.CategoryListParams;
|
|||
import org.apache.lucene.facet.index.params.FacetIndexingParams;
|
||||
import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -140,7 +140,7 @@ public class MultiCLIndexer {
|
|||
IndexWriter iw = new IndexWriter(indexDir, new IndexWriterConfig(
|
||||
ExampleUtils.EXAMPLE_VER, SimpleUtils.analyzer).setOpenMode(OpenMode.CREATE));
|
||||
// create and open a taxonomy writer
|
||||
LuceneTaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
DirectoryTaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
index(iw, taxo, iParams, docTitles, docTexts, cPaths);
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class MultiCLIndexer {
|
|||
* on error (no detailed exception handling here for sample
|
||||
* simplicity
|
||||
*/
|
||||
public static void index(IndexWriter iw, LuceneTaxonomyWriter taxo,
|
||||
public static void index(IndexWriter iw, DirectoryTaxonomyWriter taxo,
|
||||
FacetIndexingParams iParams, String[] docTitles,
|
||||
String[] docTexts, CategoryPath[][] cPaths) throws Exception {
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.lucene.facet.search.params.FacetSearchParams;
|
|||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -64,7 +64,7 @@ public class MultiCLSearcher {
|
|||
|
||||
// prepare index reader and taxonomy.
|
||||
IndexReader indexReader = IndexReader.open(indexDir);
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// Get results
|
||||
List<FacetResult> results = searchWithFacets(indexReader, taxo, iParams);
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.apache.lucene.facet.example.ExampleUtils;
|
|||
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -53,7 +53,7 @@ public class SimpleIndexer {
|
|||
IndexWriter iw = new IndexWriter(indexDir, new IndexWriterConfig(ExampleUtils.EXAMPLE_VER, SimpleUtils.analyzer));
|
||||
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
|
||||
// loop over sample documents
|
||||
int nDocsAdded = 0;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.apache.lucene.facet.example.ExampleResult;
|
|||
import org.apache.lucene.facet.example.ExampleUtils;
|
||||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -56,7 +56,7 @@ public class SimpleMain {
|
|||
SimpleIndexer.index(indexDir, taxoDir);
|
||||
|
||||
// open readers
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
IndexReader indexReader = IndexReader.open(indexDir, true);
|
||||
|
||||
ExampleUtils.log("search the sample documents...");
|
||||
|
@ -81,7 +81,7 @@ public class SimpleMain {
|
|||
SimpleIndexer.index(indexDir, taxoDir);
|
||||
|
||||
// open readers
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
IndexReader indexReader = IndexReader.open(indexDir, true);
|
||||
|
||||
ExampleUtils.log("search the sample documents...");
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.apache.lucene.store.Directory;
|
|||
|
||||
import org.apache.lucene.facet.index.params.CategoryListParams;
|
||||
import org.apache.lucene.facet.index.params.FacetIndexingParams;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.OrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.encoding.IntDecoder;
|
||||
import org.apache.lucene.util.encoding.IntEncoder;
|
||||
|
|
|
@ -2,9 +2,8 @@ package org.apache.lucene.facet.taxonomy;
|
|||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.util.TwoPhaseCommit;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -52,7 +51,7 @@ import org.apache.lucene.index.IndexWriter;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public interface TaxonomyWriter extends Closeable {
|
||||
public interface TaxonomyWriter extends Closeable, TwoPhaseCommit {
|
||||
|
||||
/**
|
||||
* addCategory() adds a category with a given path name to the taxonomy,
|
||||
|
@ -66,32 +65,6 @@ public interface TaxonomyWriter extends Closeable {
|
|||
*/
|
||||
public int addCategory(CategoryPath categoryPath) throws IOException;
|
||||
|
||||
/**
|
||||
* Calling commit() ensures that all the categories written so far are
|
||||
* visible to a reader that is opened (or reopened) after that call.
|
||||
* When the index is closed(), commit() is also implicitly done.
|
||||
*/
|
||||
public void commit() throws IOException;
|
||||
|
||||
/**
|
||||
* Like commit(), but also store properties with the index. These properties
|
||||
* are retrievable by {@link TaxonomyReader#getCommitUserData}.
|
||||
* See {@link IndexWriter#commit(Map)}.
|
||||
*/
|
||||
public void commit(Map<String,String> commitUserData) throws IOException;
|
||||
|
||||
/**
|
||||
* prepare most of the work needed for a two-phase commit.
|
||||
* See {@link IndexWriter#prepareCommit}.
|
||||
*/
|
||||
public void prepareCommit() throws IOException;
|
||||
|
||||
/**
|
||||
* Like above, and also prepares to store user data with the index.
|
||||
* See {@link IndexWriter#prepareCommit(Map)}
|
||||
*/
|
||||
public void prepareCommit(Map<String,String> commitUserData) throws IOException;
|
||||
|
||||
/**
|
||||
* getParent() returns the ordinal of the parent category of the category
|
||||
* with the given ordinal.
|
||||
|
@ -108,8 +81,8 @@ public interface TaxonomyWriter extends Closeable {
|
|||
* ordinal), an ArrayIndexOutOfBoundsException is thrown. However, it is
|
||||
* expected that getParent will only be called for ordinals which are
|
||||
* already known to be in the taxonomy.
|
||||
* <P>
|
||||
* TODO (Facet): instead of a getParent(ordinal) method, consider having a
|
||||
* <P>
|
||||
* getCategory(categorypath, prefixlen) which is similar to addCategory
|
||||
* except it doesn't add new categories; This method can be used to get
|
||||
* the ordinals of all prefixes of the given category, and it can use
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
@ -11,7 +11,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.Consts.LoadFullPathOnly;
|
||||
import org.apache.lucene.facet.taxonomy.directory.Consts.LoadFullPathOnly;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.index.DocsEnum;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
|
@ -40,24 +40,21 @@ import org.apache.lucene.util.collections.LRUHashMap;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* LuceneTaxonomyReader is a {@link TaxonomyReader} which retrieves stored
|
||||
* taxonomy information from a separate Lucene index. By using a Lucene index,
|
||||
* rather than some specialized file format, we get for "free" its correctness
|
||||
* (especially regarding concurrency), and the ability to save it on any
|
||||
* implementation of Directory (and not just the file system).
|
||||
/**
|
||||
* A {@link TaxonomyReader} which retrieves stored taxonomy information from a
|
||||
* {@link Directory}.
|
||||
* <P>
|
||||
* Reading from the on-disk index on every method call is too slow, so this
|
||||
* implementation employs caching: Some methods cache recent requests and
|
||||
* their results, while other methods prefetch all the data into memory
|
||||
* and then provide answers directly from in-memory tables. See the
|
||||
* documentation of individual methods for comments on their performance.
|
||||
* implementation employs caching: Some methods cache recent requests and their
|
||||
* results, while other methods prefetch all the data into memory and then
|
||||
* provide answers directly from in-memory tables. See the documentation of
|
||||
* individual methods for comments on their performance.
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class LuceneTaxonomyReader implements TaxonomyReader {
|
||||
public class DirectoryTaxonomyReader implements TaxonomyReader {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(LuceneTaxonomyReader.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(DirectoryTaxonomyReader.class.getName());
|
||||
|
||||
private IndexReader indexReader;
|
||||
|
||||
|
@ -111,8 +108,7 @@ public class LuceneTaxonomyReader implements TaxonomyReader {
|
|||
* @throws CorruptIndexException if the Taxonomy is corrupted.
|
||||
* @throws IOException if another error occurred.
|
||||
*/
|
||||
public LuceneTaxonomyReader(Directory directory)
|
||||
throws CorruptIndexException, IOException {
|
||||
public DirectoryTaxonomyReader(Directory directory) throws IOException {
|
||||
this.indexReader = openIndexReader(directory);
|
||||
|
||||
// These are the default cache sizes; they can be configured after
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
|
@ -64,29 +64,24 @@ import org.apache.lucene.facet.taxonomy.writercache.lru.LruTaxonomyWriterCache;
|
|||
*/
|
||||
|
||||
/**
|
||||
* {@link TaxonomyWriter} which uses a Lucene index to store the taxonomy
|
||||
* {@link TaxonomyWriter} which uses a {@link Directory} to store the taxonomy
|
||||
* information on disk, and keeps an additional in-memory cache of some or all
|
||||
* categories.
|
||||
* <P>
|
||||
* By using a Lucene index to store the information on disk, rather than some
|
||||
* specialized file format, we get for "free" Lucene's correctness (especially
|
||||
* regarding multi-process concurrency), and the ability to write to any
|
||||
* implementation of Directory (and not just the file system).
|
||||
* <P>
|
||||
* In addition to the permanently-stored Lucene index, efficiency dictates that
|
||||
* we also keep an in-memory cache of <B>recently seen</B> or <B>all</B>
|
||||
* categories, so that we do not need to go back to disk for every category
|
||||
* addition to see which ordinal this category already has, if any. A
|
||||
* {@link TaxonomyWriterCache} object determines the specific caching algorithm
|
||||
* used.
|
||||
* <p>
|
||||
* In addition to the permanently-stored information in the {@link Directory},
|
||||
* efficiency dictates that we also keep an in-memory cache of <B>recently
|
||||
* seen</B> or <B>all</B> categories, so that we do not need to go back to disk
|
||||
* for every category addition to see which ordinal this category already has,
|
||||
* if any. A {@link TaxonomyWriterCache} object determines the specific caching
|
||||
* algorithm used.
|
||||
* <p>
|
||||
* This class offers some hooks for extending classes to control the
|
||||
* {@link IndexWriter} instance that is used. See {@link #openLuceneIndex} and
|
||||
* {@link #closeLuceneIndex()} .
|
||||
* {@link IndexWriter} instance that is used. See {@link #openIndexWriter} and
|
||||
* {@link #closeIndexWriter()} .
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
||||
public class DirectoryTaxonomyWriter implements TaxonomyWriter {
|
||||
|
||||
protected IndexWriter indexWriter;
|
||||
private int nextID;
|
||||
|
@ -171,12 +166,12 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* @throws IOException
|
||||
* if another error occurred.
|
||||
*/
|
||||
public LuceneTaxonomyWriter(Directory directory, OpenMode openMode,
|
||||
public DirectoryTaxonomyWriter(Directory directory, OpenMode openMode,
|
||||
TaxonomyWriterCache cache)
|
||||
throws CorruptIndexException, LockObtainFailedException,
|
||||
IOException {
|
||||
|
||||
openLuceneIndex(directory, openMode);
|
||||
openIndexWriter(directory, openMode);
|
||||
reader = null;
|
||||
|
||||
FieldType ft = new FieldType(TextField.TYPE_UNSTORED);
|
||||
|
@ -218,18 +213,20 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* etc.<br>
|
||||
* <b>NOTE:</b> the instance this method returns will be closed upon calling
|
||||
* to {@link #close()}. If you wish to do something different, you should
|
||||
* override {@link #closeLuceneIndex()}.
|
||||
* override {@link #closeIndexWriter()}.
|
||||
*
|
||||
* @param directory the {@link Directory} on top of wich an
|
||||
* {@link IndexWriter} should be opened.
|
||||
* @param openMode see {@link OpenMode}
|
||||
* @param directory
|
||||
* the {@link Directory} on top of which an {@link IndexWriter}
|
||||
* should be opened.
|
||||
* @param openMode
|
||||
* see {@link OpenMode}
|
||||
*/
|
||||
protected void openLuceneIndex (Directory directory, OpenMode openMode)
|
||||
throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
protected void openIndexWriter(Directory directory, OpenMode openMode)
|
||||
throws IOException {
|
||||
// Make sure we use a MergePolicy which merges segments in-order and thus
|
||||
// keeps the doc IDs ordered as well (this is crucial for the taxonomy
|
||||
// index).
|
||||
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_30,
|
||||
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40,
|
||||
new KeywordAnalyzer()).setOpenMode(openMode).setMergePolicy(
|
||||
new LogByteSizeMergePolicy());
|
||||
indexWriter = new IndexWriter(directory, config);
|
||||
|
@ -250,7 +247,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* Creates a new instance with a default cached as defined by
|
||||
* {@link #defaultTaxonomyWriterCache()}.
|
||||
*/
|
||||
public LuceneTaxonomyWriter(Directory directory, OpenMode openMode)
|
||||
public DirectoryTaxonomyWriter(Directory directory, OpenMode openMode)
|
||||
throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
this(directory, openMode, defaultTaxonomyWriterCache());
|
||||
}
|
||||
|
@ -269,7 +266,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
|
||||
// convenience constructors:
|
||||
|
||||
public LuceneTaxonomyWriter(Directory d)
|
||||
public DirectoryTaxonomyWriter(Directory d)
|
||||
throws CorruptIndexException, LockObtainFailedException,
|
||||
IOException {
|
||||
this(d, OpenMode.CREATE_OR_APPEND);
|
||||
|
@ -280,8 +277,9 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* which commits whatever changes made to it to the underlying
|
||||
* {@link Directory}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void close() throws CorruptIndexException, IOException {
|
||||
closeLuceneIndex();
|
||||
closeIndexWriter();
|
||||
closeResources();
|
||||
}
|
||||
|
||||
|
@ -316,9 +314,9 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
|
||||
/**
|
||||
* A hook for extending classes to control closing the {@link IndexWriter}
|
||||
* returned by {@link #openLuceneIndex}.
|
||||
* returned by {@link #openIndexWriter}.
|
||||
*/
|
||||
protected void closeLuceneIndex() throws CorruptIndexException, IOException {
|
||||
protected void closeIndexWriter() throws CorruptIndexException, IOException {
|
||||
if (indexWriter != null) {
|
||||
indexWriter.close();
|
||||
indexWriter = null;
|
||||
|
@ -413,6 +411,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
// potentially even trigger a lengthy merge) locks out other addCategory()
|
||||
// calls - even those which could immediately return a cached value.
|
||||
// We definitely need to fix this situation!
|
||||
@Override
|
||||
public synchronized int addCategory(CategoryPath categoryPath)
|
||||
throws IOException {
|
||||
// If the category is already in the cache and/or the taxonomy, we
|
||||
|
@ -578,6 +577,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* When the index is closed(), commit() is also implicitly done.
|
||||
* See {@link TaxonomyWriter#commit()}
|
||||
*/
|
||||
@Override
|
||||
public synchronized void commit() throws CorruptIndexException, IOException {
|
||||
indexWriter.commit();
|
||||
refreshReader();
|
||||
|
@ -585,9 +585,10 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
|
||||
/**
|
||||
* Like commit(), but also store properties with the index. These properties
|
||||
* are retrievable by {@link LuceneTaxonomyReader#getCommitUserData}.
|
||||
* are retrievable by {@link DirectoryTaxonomyReader#getCommitUserData}.
|
||||
* See {@link TaxonomyWriter#commit(Map)}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void commit(Map<String,String> commitUserData) throws CorruptIndexException, IOException {
|
||||
indexWriter.commit(commitUserData);
|
||||
refreshReader();
|
||||
|
@ -597,6 +598,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* prepare most of the work needed for a two-phase commit.
|
||||
* See {@link IndexWriter#prepareCommit}.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void prepareCommit() throws CorruptIndexException, IOException {
|
||||
indexWriter.prepareCommit();
|
||||
}
|
||||
|
@ -605,6 +607,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* Like above, and also prepares to store user data with the index.
|
||||
* See {@link IndexWriter#prepareCommit(Map)}
|
||||
*/
|
||||
@Override
|
||||
public synchronized void prepareCommit(Map<String,String> commitUserData) throws CorruptIndexException, IOException {
|
||||
indexWriter.prepareCommit(commitUserData);
|
||||
}
|
||||
|
@ -620,6 +623,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
* a category is added to the taxonomy, its ancestors are also added
|
||||
* automatically (including the root, which always get ordinal 0).
|
||||
*/
|
||||
@Override
|
||||
synchronized public int getSize() {
|
||||
return indexWriter.maxDoc();
|
||||
}
|
||||
|
@ -720,6 +724,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
}
|
||||
return parentArray;
|
||||
}
|
||||
@Override
|
||||
public int getParent(int ordinal) throws IOException {
|
||||
// Note: the following if() just enforces that a user can never ask
|
||||
// for the parent of a nonexistant category - even if the parent array
|
||||
|
@ -930,13 +935,17 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
*/
|
||||
public static final class MemoryOrdinalMap implements OrdinalMap {
|
||||
int[] map;
|
||||
@Override
|
||||
public void setSize(int taxonomySize) {
|
||||
map = new int[taxonomySize];
|
||||
}
|
||||
@Override
|
||||
public void addMapping(int origOrdinal, int newOrdinal) {
|
||||
map[origOrdinal] = newOrdinal;
|
||||
}
|
||||
@Override
|
||||
public void addDone() { /* nothing to do */ }
|
||||
@Override
|
||||
public int[] getMap() {
|
||||
return map;
|
||||
}
|
||||
|
@ -955,15 +964,18 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
new FileOutputStream(tmpfile)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMapping(int origOrdinal, int newOrdinal) throws IOException {
|
||||
out.writeInt(origOrdinal);
|
||||
out.writeInt(newOrdinal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(int taxonomySize) throws IOException {
|
||||
out.writeInt(taxonomySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDone() throws IOException {
|
||||
if (out!=null) {
|
||||
out.close();
|
||||
|
@ -973,6 +985,7 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
|
||||
int[] map = null;
|
||||
|
||||
@Override
|
||||
public int[] getMap() throws IOException {
|
||||
if (map!=null) {
|
||||
return map;
|
||||
|
@ -1005,4 +1018,10 @@ public class LuceneTaxonomyWriter implements TaxonomyWriter {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() throws IOException {
|
||||
indexWriter.rollback();
|
||||
refreshReader();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package org.apache.lucene.facet.taxonomy.writercache;
|
||||
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -23,7 +23,7 @@ import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
|||
/**
|
||||
* TaxonomyWriterCache is a relatively simple interface for a cache of
|
||||
* category->ordinal mappings, used in TaxonomyWriter implementations
|
||||
* (such as {@link LuceneTaxonomyWriter}).
|
||||
* (such as {@link DirectoryTaxonomyWriter}).
|
||||
* <P>
|
||||
* It basically has put() methods for adding a mapping, and get() for looking
|
||||
* a mapping up the cache. The cache does <B>not</B> guarantee to hold
|
||||
|
|
|
@ -119,7 +119,7 @@ class NameIntCacheLRU {
|
|||
* If cache is full remove least recently used entries from cache.
|
||||
* Return true if anything was removed, false otherwise.
|
||||
*
|
||||
* See comment in {@link LuceneTaxonomyWriter#addToCache(String, Integer)}
|
||||
* See comment in {@link DirectoryTaxonomyWriter#addToCache(String, Integer)}
|
||||
* for an explanation why we clean 2/3rds of the cache, and not just one
|
||||
* entry.
|
||||
*/
|
||||
|
|
|
@ -43,8 +43,8 @@ import org.apache.lucene.facet.search.results.FacetResultNode;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -137,7 +137,7 @@ public abstract class FacetTestBase extends LuceneTestCase {
|
|||
}
|
||||
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random, indexDir, getIndexWriterConfig(getAnalyzer()));
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
|
||||
|
||||
populateIndex(iw, taxo, getFacetIndexingParams(partitionSize));
|
||||
|
||||
|
@ -148,7 +148,7 @@ public abstract class FacetTestBase extends LuceneTestCase {
|
|||
iw.close();
|
||||
|
||||
// prepare for searching
|
||||
taxoReader = new LuceneTaxonomyReader(taxoDir);
|
||||
taxoReader = new DirectoryTaxonomyReader(taxoDir);
|
||||
indexReader = IndexReader.open(indexDir);
|
||||
searcher = newSearcher(indexReader);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.apache.lucene.facet.search.params.FacetSearchParams;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -69,7 +69,7 @@ public class FacetTestUtils {
|
|||
IndexTaxonomyReaderPair pair = new IndexTaxonomyReaderPair();
|
||||
pair.indexReader = IndexReader.open(dirs[i][0]);
|
||||
pair.indexSearcher = new IndexSearcher(pair.indexReader);
|
||||
pair.taxReader = new LuceneTaxonomyReader(dirs[i][1]);
|
||||
pair.taxReader = new DirectoryTaxonomyReader(dirs[i][1]);
|
||||
pairs[i] = pair;
|
||||
}
|
||||
return pairs;
|
||||
|
@ -83,7 +83,7 @@ public class FacetTestUtils {
|
|||
pair.indexWriter = new IndexWriter(dirs[i][0], new IndexWriterConfig(
|
||||
LuceneTestCase.TEST_VERSION_CURRENT, new StandardAnalyzer(
|
||||
LuceneTestCase.TEST_VERSION_CURRENT)));
|
||||
pair.taxWriter = new LuceneTaxonomyWriter(dirs[i][1]);
|
||||
pair.taxWriter = new DirectoryTaxonomyWriter(dirs[i][1]);
|
||||
pair.indexWriter.commit();
|
||||
pair.taxWriter.commit();
|
||||
pairs[i] = pair;
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
|
|||
import org.apache.lucene.facet.search.DrillDown;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -58,7 +58,7 @@ public class TwoEnhancementsTest extends LuceneTestCase {
|
|||
|
||||
RandomIndexWriter indexWriter = new RandomIndexWriter(random, indexDir, newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
// a category document builder will add the categories to a document
|
||||
// once build() is called
|
||||
|
@ -103,7 +103,7 @@ public class TwoEnhancementsTest extends LuceneTestCase {
|
|||
|
||||
RandomIndexWriter indexWriter = new RandomIndexWriter(random, indexDir, newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
TaxonomyWriter taxo = new LuceneTaxonomyWriter(taxoDir);
|
||||
TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
// a category document builder will add the categories to a document
|
||||
// once build() is called
|
||||
|
|
|
@ -16,8 +16,8 @@ import org.apache.lucene.facet.index.CategoryContainer;
|
|||
import org.apache.lucene.facet.index.attributes.CategoryAttributeImpl;
|
||||
import org.apache.lucene.facet.index.attributes.CategoryProperty;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -59,7 +59,7 @@ public class CustomAssociationPropertyTest extends LuceneTestCase {
|
|||
|
||||
RandomIndexWriter w = new RandomIndexWriter(random, iDir,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
|
||||
LuceneTaxonomyWriter taxoW = new LuceneTaxonomyWriter(tDir);
|
||||
DirectoryTaxonomyWriter taxoW = new DirectoryTaxonomyWriter(tDir);
|
||||
|
||||
CategoryContainer cc = new CategoryContainer();
|
||||
EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(taxoW, iParams);
|
||||
|
@ -75,7 +75,7 @@ public class CustomAssociationPropertyTest extends LuceneTestCase {
|
|||
IndexReader reader = w.getReader();
|
||||
w.close();
|
||||
|
||||
LuceneTaxonomyReader taxo = new LuceneTaxonomyReader(tDir);
|
||||
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(tDir);
|
||||
String field = iParams.getCategoryListParams(new CategoryPath("0")).getTerm().field();
|
||||
AssociationsPayloadIterator api = new AssociationsPayloadIterator(reader, field);
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.apache.lucene.facet.search.params.FacetSearchParams;
|
|||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.search.results.FacetResultNode;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -68,7 +68,7 @@ public class FacetsPayloadProcessorProviderTest extends LuceneTestCase {
|
|||
|
||||
private void verifyResults(Directory dir, Directory taxDir) throws IOException {
|
||||
IndexReader reader1 = IndexReader.open(dir);
|
||||
LuceneTaxonomyReader taxReader = new LuceneTaxonomyReader(taxDir);
|
||||
DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir);
|
||||
IndexSearcher searcher = newSearcher(reader1);
|
||||
FacetSearchParams fsp = new FacetSearchParams();
|
||||
fsp.addFacetRequest(new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
|
||||
|
@ -94,7 +94,7 @@ public class FacetsPayloadProcessorProviderTest extends LuceneTestCase {
|
|||
new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random, dir, config);
|
||||
|
||||
LuceneTaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(taxDir);
|
||||
DirectoryTaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(taxDir);
|
||||
for (int i = 1; i <= NUM_DOCS; i++) {
|
||||
Document doc = new Document();
|
||||
List<CategoryPath> categoryPaths = new ArrayList<CategoryPath>(i + 1);
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -48,7 +48,7 @@ public class OrdinalPolicyTest extends LuceneTestCase {
|
|||
public void testNonTopLevelOrdinalPolicy() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
TaxonomyWriter taxonomy = null;
|
||||
taxonomy = new LuceneTaxonomyWriter(dir);
|
||||
taxonomy = new DirectoryTaxonomyWriter(dir);
|
||||
|
||||
int[] topLevelOrdinals = new int[10];
|
||||
String[] topLevelStrings = new String[10];
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.apache.lucene.facet.index.categorypolicy.NonTopLevelPathPolicy;
|
|||
import org.apache.lucene.facet.index.categorypolicy.PathPolicy;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -54,7 +54,7 @@ public class PathPolicyTest extends LuceneTestCase {
|
|||
public void testNonTopLevelPathPolicy() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
TaxonomyWriter taxonomy = null;
|
||||
taxonomy = new LuceneTaxonomyWriter(dir);
|
||||
taxonomy = new DirectoryTaxonomyWriter(dir);
|
||||
|
||||
CategoryPath[] topLevelPaths = new CategoryPath[10];
|
||||
String[] topLevelStrings = new String[10];
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.apache.lucene.facet.index.streaming.CategoryAttributesStream;
|
|||
import org.apache.lucene.facet.index.streaming.CategoryListTokenizer;
|
||||
import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -50,7 +50,7 @@ public class CategoryParentsStreamTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testStreamDefaultParams() throws IOException {
|
||||
Directory directory = newDirectory();
|
||||
TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
|
||||
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
|
||||
directory);
|
||||
CategoryParentsStream stream = new CategoryParentsStream(
|
||||
new CategoryAttributesStream(categoryContainer),
|
||||
|
@ -77,7 +77,7 @@ public class CategoryParentsStreamTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testStreamNonTopLevelParams() throws IOException {
|
||||
Directory directory = newDirectory();
|
||||
final TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
|
||||
final TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
|
||||
directory);
|
||||
FacetIndexingParams indexingParams = new DefaultFacetIndexingParams() {
|
||||
@Override
|
||||
|
@ -118,7 +118,7 @@ public class CategoryParentsStreamTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testNoRetainableAttributes() throws IOException, FacetException {
|
||||
Directory directory = newDirectory();
|
||||
TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(directory);
|
||||
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(directory);
|
||||
|
||||
new CategoryParentsStream(new CategoryAttributesStream(categoryContainer),
|
||||
taxonomyWriter, new DefaultFacetIndexingParams());
|
||||
|
@ -152,7 +152,7 @@ public class CategoryParentsStreamTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testRetainableAttributes() throws IOException, FacetException {
|
||||
Directory directory = newDirectory();
|
||||
TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
|
||||
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
|
||||
directory);
|
||||
|
||||
FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.apache.lucene.facet.index.streaming.CategoryAttributesStream;
|
|||
import org.apache.lucene.facet.index.streaming.CategoryTokenizer;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -47,7 +47,7 @@ public class CategoryTokenizerTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testTokensDefaultParams() throws IOException {
|
||||
Directory directory = newDirectory();
|
||||
TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
|
||||
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
|
||||
directory);
|
||||
DefaultFacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
|
||||
CategoryTokenizer tokenizer = new CategoryTokenizer(
|
||||
|
@ -86,7 +86,7 @@ public class CategoryTokenizerTest extends CategoryContainerTestBase {
|
|||
@Test
|
||||
public void testLongCategoryPath() throws IOException {
|
||||
Directory directory = newDirectory();
|
||||
TaxonomyWriter taxonomyWriter = new LuceneTaxonomyWriter(
|
||||
TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(
|
||||
directory);
|
||||
|
||||
List<CategoryPath> longCategory = new ArrayList<CategoryPath>();
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
|
|||
import org.apache.lucene.facet.search.params.FacetSearchParams;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -53,7 +53,7 @@ public class DrillDownTest extends LuceneTestCase {
|
|||
private FacetSearchParams defaultParams = new FacetSearchParams();
|
||||
private FacetSearchParams nonDefaultParams;
|
||||
private static IndexReader reader;
|
||||
private static LuceneTaxonomyReader taxo;
|
||||
private static DirectoryTaxonomyReader taxo;
|
||||
private static Directory dir;
|
||||
private static Directory taxoDir;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class DrillDownTest extends LuceneTestCase {
|
|||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
|
||||
|
||||
taxoDir = newDirectory();
|
||||
TaxonomyWriter taxoWriter = new LuceneTaxonomyWriter(taxoDir);
|
||||
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
ArrayList<CategoryPath> paths = new ArrayList<CategoryPath>();
|
||||
|
@ -100,7 +100,7 @@ public class DrillDownTest extends LuceneTestCase {
|
|||
reader = writer.getReader();
|
||||
writer.close();
|
||||
|
||||
taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,6 +149,8 @@ public class DrillDownTest extends LuceneTestCase {
|
|||
Query q4 = DrillDown.query(defaultParams, fooQuery, new CategoryPath("b"));
|
||||
docs = searcher.search(q4, 100);
|
||||
assertEquals(10, docs.totalHits);
|
||||
|
||||
searcher.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -170,6 +172,8 @@ public class DrillDownTest extends LuceneTestCase {
|
|||
Query q4 = DrillDown.query(fooQuery, new CategoryPath("b"));
|
||||
docs = searcher.search(q4, 100);
|
||||
assertEquals(10, docs.totalHits);
|
||||
|
||||
searcher.close();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -38,8 +38,8 @@ import org.apache.lucene.facet.search.results.FacetResultNode;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -67,7 +67,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, dirs[0][0], newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0][1], OpenMode.CREATE);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1], OpenMode.CREATE);
|
||||
|
||||
/**
|
||||
* Configure with no custom counting lists
|
||||
|
@ -80,7 +80,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
tw.commit();
|
||||
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0][1]);
|
||||
|
||||
// prepare searcher to search against
|
||||
IndexSearcher searcher = newSearcher(ir);
|
||||
|
@ -109,7 +109,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, dirs[0][0], newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0][1],
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
|
||||
OpenMode.CREATE);
|
||||
|
||||
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
|
||||
|
@ -121,7 +121,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
tw.commit();
|
||||
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0][1]);
|
||||
|
||||
// prepare searcher to search against
|
||||
IndexSearcher searcher = newSearcher(ir);
|
||||
|
@ -150,7 +150,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, dirs[0][0], newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0][1],
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
|
||||
OpenMode.CREATE);
|
||||
|
||||
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
|
||||
|
@ -164,7 +164,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
tw.commit();
|
||||
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0][1]);
|
||||
|
||||
// prepare searcher to search against
|
||||
IndexSearcher searcher = newSearcher(ir);
|
||||
|
@ -199,7 +199,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, dirs[0][0], newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0][1], OpenMode.CREATE);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1], OpenMode.CREATE);
|
||||
|
||||
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
|
||||
iParams.addCategoryListParams(new CategoryPath("Band"),
|
||||
|
@ -212,7 +212,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
tw.commit();
|
||||
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0][1]);
|
||||
|
||||
// prepare searcher to search against
|
||||
IndexSearcher searcher = newSearcher(ir);
|
||||
|
@ -240,7 +240,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, dirs[0][0], newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
// create and open a taxonomy writer
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0][1],
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0][1],
|
||||
OpenMode.CREATE);
|
||||
|
||||
PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();
|
||||
|
@ -257,7 +257,7 @@ public class TestMultipleCategoryLists extends LuceneTestCase {
|
|||
tw.commit();
|
||||
|
||||
// prepare index reader and taxonomy.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0][1]);
|
||||
|
||||
// prepare searcher to search against
|
||||
IndexSearcher searcher = newSearcher(ir);
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.apache.lucene.facet.search.results.FacetResult;
|
|||
import org.apache.lucene.facet.search.results.FacetResultNode;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.util.PartitionsUtils;
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class TestTopKInEachNodeResultHandler extends LuceneTestCase {
|
|||
RandomIndexWriter iw = new RandomIndexWriter(random, iDir,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT,
|
||||
new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(tDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(tDir);
|
||||
prvt_add(iParams, iw, tw, "a", "b");
|
||||
prvt_add(iParams, iw, tw, "a", "b", "1");
|
||||
prvt_add(iParams, iw, tw, "a", "b", "1");
|
||||
|
@ -104,7 +104,7 @@ public class TestTopKInEachNodeResultHandler extends LuceneTestCase {
|
|||
tw.close();
|
||||
|
||||
IndexSearcher is = newSearcher(ir);
|
||||
LuceneTaxonomyReader tr = new LuceneTaxonomyReader(tDir);
|
||||
DirectoryTaxonomyReader tr = new DirectoryTaxonomyReader(tDir);
|
||||
|
||||
// Get all of the documents and run the query, then do different
|
||||
// facet counts and compare to control
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.apache.lucene.facet.search.results.FacetResultNode;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.SlowRAMDirectory;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
@ -67,12 +67,12 @@ public class TestTotalFacetCountsCache extends LuceneTestCase {
|
|||
*/
|
||||
private static class TFCThread extends Thread {
|
||||
private final IndexReader r;
|
||||
private final LuceneTaxonomyReader tr;
|
||||
private final DirectoryTaxonomyReader tr;
|
||||
private final FacetIndexingParams iParams;
|
||||
|
||||
TotalFacetCounts tfc;
|
||||
|
||||
public TFCThread(IndexReader r, LuceneTaxonomyReader tr, FacetIndexingParams iParams) {
|
||||
public TFCThread(IndexReader r, DirectoryTaxonomyReader tr, FacetIndexingParams iParams) {
|
||||
this.r = r;
|
||||
this.tr = tr;
|
||||
this.iParams = iParams;
|
||||
|
@ -156,7 +156,7 @@ public class TestTotalFacetCountsCache extends LuceneTestCase {
|
|||
|
||||
// Open the slow readers
|
||||
IndexReader slowIndexReader = IndexReader.open(indexDir);
|
||||
TaxonomyReader slowTaxoReader = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader slowTaxoReader = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// Class to perform search and return results as threads
|
||||
class Multi extends Thread {
|
||||
|
@ -421,7 +421,7 @@ public class TestTotalFacetCountsCache extends LuceneTestCase {
|
|||
// Write index using 'normal' directories
|
||||
IndexWriter w = new IndexWriter(indexDir, new IndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
|
||||
LuceneTaxonomyWriter tw = new LuceneTaxonomyWriter(taxoDir);
|
||||
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(taxoDir);
|
||||
DefaultFacetIndexingParams iParams = new DefaultFacetIndexingParams();
|
||||
// Add documents and facets
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
|
@ -434,7 +434,7 @@ public class TestTotalFacetCountsCache extends LuceneTestCase {
|
|||
taxoDir.setSleepMillis(1);
|
||||
|
||||
IndexReader r = IndexReader.open(indexDir);
|
||||
LuceneTaxonomyReader tr = new LuceneTaxonomyReader(taxoDir);
|
||||
DirectoryTaxonomyReader tr = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// Create and start threads. Thread1 should lock the cache and calculate
|
||||
// the TFC array. The second thread should block until the first is
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.apache.lucene.facet.search.params.association.AssociationIntSumFacetR
|
|||
import org.apache.lucene.facet.search.results.FacetResult;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -69,7 +69,7 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
|
|||
RandomIndexWriter writer = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT,
|
||||
new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
|
||||
|
||||
TaxonomyWriter taxoWriter = new LuceneTaxonomyWriter(taxoDir);
|
||||
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
EnhancementsDocumentBuilder builder = new EnhancementsDocumentBuilder(
|
||||
taxoWriter, new DefaultEnhancementsIndexingParams(
|
||||
|
@ -106,7 +106,7 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testIntSumAssociation() throws Exception {
|
||||
LuceneTaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// facet requests for two facets
|
||||
FacetSearchParams fsp = new FacetSearchParams();
|
||||
|
@ -132,7 +132,7 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
|
|||
|
||||
@Test
|
||||
public void testFloatSumAssociation() throws Exception {
|
||||
LuceneTaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// facet requests for two facets
|
||||
FacetSearchParams fsp = new FacetSearchParams();
|
||||
|
@ -161,7 +161,7 @@ public class AssociationsFacetRequestTest extends LuceneTestCase {
|
|||
// Same category list cannot be aggregated by two different aggregators. If
|
||||
// you want to do that, you need to separate the categories into two
|
||||
// category list (you'll still have one association list).
|
||||
LuceneTaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
|
||||
// facet requests for two facets
|
||||
FacetSearchParams fsp = new FacetSearchParams();
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.facet.search.FacetResultsHandler;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -58,8 +58,8 @@ public class FacetRequestTest extends LuceneTestCase {
|
|||
// create empty indexes, so that LTR ctor won't complain about a missing index.
|
||||
new IndexWriter(dir1, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
|
||||
new IndexWriter(dir2, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
|
||||
TaxonomyReader tr1 = new LuceneTaxonomyReader(dir1);
|
||||
TaxonomyReader tr2 = new LuceneTaxonomyReader(dir2);
|
||||
TaxonomyReader tr1 = new DirectoryTaxonomyReader(dir1);
|
||||
TaxonomyReader tr2 = new DirectoryTaxonomyReader(dir2);
|
||||
FacetResultsHandler frh1 = fr.createFacetResultsHandler(tr1);
|
||||
FacetResultsHandler frh2 = fr.createFacetResultsHandler(tr2);
|
||||
assertTrue("should not return the same FacetResultHandler instance for different TaxonomyReader instances", frh1 != frh2);
|
||||
|
@ -77,7 +77,7 @@ public class FacetRequestTest extends LuceneTestCase {
|
|||
Directory dir = newDirectory();
|
||||
// create empty indexes, so that LTR ctor won't complain about a missing index.
|
||||
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null)).close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dir);
|
||||
FacetResultsHandler frh = fr.createFacetResultsHandler(tr);
|
||||
fr.setDepth(10);
|
||||
assertEquals(FacetRequest.DEFAULT_DEPTH, frh.getFacetRequest().getDepth());
|
||||
|
|
|
@ -8,8 +8,8 @@ import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.util.PartitionsUtils;
|
||||
|
||||
/**
|
||||
|
@ -37,8 +37,8 @@ public class FacetSearchParamsTest extends LuceneTestCase {
|
|||
assertEquals("unexpected default facet indexing params class", DefaultFacetIndexingParams.class.getName(), fsp.getFacetIndexingParams().getClass().getName());
|
||||
assertEquals("no facet requests should be added by default", 0, fsp.getFacetRequests().size());
|
||||
Directory dir = newDirectory();
|
||||
new LuceneTaxonomyWriter(dir).close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dir);
|
||||
new DirectoryTaxonomyWriter(dir).close();
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dir);
|
||||
assertEquals("unexpected partition offset for 0 categories", 1, PartitionsUtils.partitionOffset(fsp, 1, tr));
|
||||
assertEquals("unexpected partition size for 0 categories", 1, PartitionsUtils.partitionSize(fsp,tr));
|
||||
tr.close();
|
||||
|
@ -56,11 +56,11 @@ public class FacetSearchParamsTest extends LuceneTestCase {
|
|||
public void testPartitionSizeWithCategories() throws Exception {
|
||||
FacetSearchParams fsp = new FacetSearchParams();
|
||||
Directory dir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(dir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(dir);
|
||||
tw.addCategory(new CategoryPath("a"));
|
||||
tw.commit();
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dir);
|
||||
assertEquals("unexpected partition offset for 1 categories", 2, PartitionsUtils.partitionOffset(fsp, 1, tr));
|
||||
assertEquals("unexpected partition size for 1 categories", 2, PartitionsUtils.partitionSize(fsp,tr));
|
||||
tr.close();
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.apache.lucene.facet.search.results.IntermediateFacetResult;
|
|||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.util.ScoredDocIdsUtils;
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ public class MultiIteratorsPerCLParamsTest extends LuceneTestCase {
|
|||
Directory taxoDir = newDirectory();
|
||||
populateIndex(iParams, indexDir, taxoDir);
|
||||
|
||||
TaxonomyReader taxo = new LuceneTaxonomyReader(taxoDir);
|
||||
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
|
||||
IndexReader reader = IndexReader.open(indexDir);
|
||||
|
||||
CategoryListCache clCache = null;
|
||||
|
@ -168,7 +168,7 @@ public class MultiIteratorsPerCLParamsTest extends LuceneTestCase {
|
|||
Directory taxoDir) throws Exception {
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random, indexDir,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false)));
|
||||
TaxonomyWriter taxoWriter = new LuceneTaxonomyWriter(taxoDir);
|
||||
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
for (CategoryPath[] categories : perDocCategories) {
|
||||
writer.addDocument(new CategoryDocumentBuilder(taxoWriter, iParams)
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.junit.Test;
|
|||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader.ChildrenArrays;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.util.SlowRAMDirectory;
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriter() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
// Also check TaxonomyWriter.getSize() - see that the taxonomy's size
|
||||
// is what we expect it to be.
|
||||
|
@ -175,7 +175,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterTwice() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
// run fillTaxonomy again - this will try to add the same categories
|
||||
// again, and check that we see the same ordinal paths again, not
|
||||
|
@ -197,10 +197,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterTwice2() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
tw = new LuceneTaxonomyWriter(indexDir);
|
||||
tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
// run fillTaxonomy again - this will try to add the same categories
|
||||
// again, and check that we see the same ordinals again, not different
|
||||
// ones, and that the number of categories hasn't grown by the new
|
||||
|
@ -222,7 +222,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
public void testWriterTwice3() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
// First, create and fill the taxonomy
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
// Now, open the same taxonomy and add the same categories again.
|
||||
|
@ -231,7 +231,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
// all into memory and close it's reader. The bug was that it closed
|
||||
// the reader, but forgot that it did (because it didn't set the reader
|
||||
// reference to null).
|
||||
tw = new LuceneTaxonomyWriter(indexDir);
|
||||
tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
// Add one new category, just to make commit() do something:
|
||||
tw.addCategory(new CategoryPath("hi"));
|
||||
|
@ -253,7 +253,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterSimpler() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
assertEquals(1, tw.getSize()); // the root only
|
||||
// Test that adding a new top-level category works
|
||||
assertEquals(1, tw.addCategory(new CategoryPath("a")));
|
||||
|
@ -297,12 +297,12 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testRootOnly() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
// right after opening the index, it should already contain the
|
||||
// root, so have size 1:
|
||||
assertEquals(1, tw.getSize());
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
assertEquals(1, tr.getSize());
|
||||
assertEquals(0, tr.getPath(0).length());
|
||||
assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0));
|
||||
|
@ -319,9 +319,9 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testRootOnly2() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.commit();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
assertEquals(1, tr.getSize());
|
||||
assertEquals(0, tr.getPath(0).length());
|
||||
assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0));
|
||||
|
@ -339,10 +339,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testReaderBasic() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
// test TaxonomyReader.getSize():
|
||||
assertEquals(expectedCategories.length, tr.getSize());
|
||||
|
@ -398,10 +398,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testReaderParent() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
// check that the parent of the root ordinal is the invalid ordinal:
|
||||
assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0));
|
||||
|
@ -463,11 +463,11 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterParent1() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
checkWriterParent(tr, tw);
|
||||
|
||||
|
@ -479,10 +479,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterParent2() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.commit();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
checkWriterParent(tr, tw);
|
||||
|
||||
|
@ -542,10 +542,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testReaderParentArray() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
int[] parents = tr.getParentArray();
|
||||
assertEquals(tr.getSize(), parents.length);
|
||||
for (int i=0; i<tr.getSize(); i++) {
|
||||
|
@ -563,10 +563,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testChildrenArrays() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
ChildrenArrays ca = tr.getChildrenArrays();
|
||||
int[] youngestChildArray = ca.getYoungestChildArray();
|
||||
assertEquals(tr.getSize(), youngestChildArray.length);
|
||||
|
@ -627,10 +627,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testChildrenArraysInvariants() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
tw.close();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
ChildrenArrays ca = tr.getChildrenArrays();
|
||||
int[] youngestChildArray = ca.getYoungestChildArray();
|
||||
assertEquals(tr.getSize(), youngestChildArray.length);
|
||||
|
@ -707,10 +707,10 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testChildrenArraysGrowth() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.addCategory(new CategoryPath("hi", "there"));
|
||||
tw.commit();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
ChildrenArrays ca = tr.getChildrenArrays();
|
||||
assertEquals(3, tr.getSize());
|
||||
assertEquals(3, ca.getOlderSiblingArray().length);
|
||||
|
@ -747,12 +747,12 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
public void testTaxonomyReaderRefreshRaces() throws Exception {
|
||||
// compute base child arrays - after first chunk, and after the other
|
||||
Directory indexDirBase = newDirectory();
|
||||
TaxonomyWriter twBase = new LuceneTaxonomyWriter(indexDirBase);
|
||||
TaxonomyWriter twBase = new DirectoryTaxonomyWriter(indexDirBase);
|
||||
twBase.addCategory(new CategoryPath("a", "0"));
|
||||
final CategoryPath abPath = new CategoryPath("a", "b");
|
||||
twBase.addCategory(abPath);
|
||||
twBase.commit();
|
||||
TaxonomyReader trBase = new LuceneTaxonomyReader(indexDirBase);
|
||||
TaxonomyReader trBase = new DirectoryTaxonomyReader(indexDirBase);
|
||||
|
||||
final ChildrenArrays ca1 = trBase.getChildrenArrays();
|
||||
|
||||
|
@ -779,12 +779,12 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
final int abOrd, final int abYoungChildBase1, final int abYoungChildBase2, final int retry)
|
||||
throws Exception {
|
||||
SlowRAMDirectory indexDir = new SlowRAMDirectory(-1,null); // no slowness for intialization
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.addCategory(new CategoryPath("a", "0"));
|
||||
tw.addCategory(abPath);
|
||||
tw.commit();
|
||||
|
||||
final TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
final TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
for (int i=0; i < 1<<10; i++) { //1024 facets
|
||||
final CategoryPath cp = new CategoryPath("a", "b", Integer.toString(i));
|
||||
tw.addCategory(cp);
|
||||
|
@ -865,9 +865,9 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testSeparateReaderAndWriter() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.commit();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
int author = 1;
|
||||
|
||||
|
@ -932,9 +932,9 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testSeparateReaderAndWriter2() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.commit();
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
|
||||
// Test getOrdinal():
|
||||
CategoryPath author = new CategoryPath("Author");
|
||||
|
@ -968,26 +968,26 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
public void testWriterLock() throws Exception {
|
||||
// native fslock impl gets angry if we use it, so use RAMDirectory explicitly.
|
||||
Directory indexDir = new RAMDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw.addCategory(new CategoryPath("hi", "there"));
|
||||
tw.commit();
|
||||
// we deliberately not close the write now, and keep it open and
|
||||
// locked.
|
||||
// Verify that the writer worked:
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
|
||||
assertEquals(2, tr.getOrdinal(new CategoryPath("hi", "there")));
|
||||
// Try to open a second writer, with the first one locking the directory.
|
||||
// We expect to get a LockObtainFailedException.
|
||||
try {
|
||||
new LuceneTaxonomyWriter(indexDir);
|
||||
new DirectoryTaxonomyWriter(indexDir);
|
||||
fail("should have failed to write in locked directory");
|
||||
} catch (LockObtainFailedException e) {
|
||||
// this is what we expect to happen.
|
||||
}
|
||||
// Remove the lock, and now the open should succeed, and we can
|
||||
// write to the new writer.
|
||||
LuceneTaxonomyWriter.unlock(indexDir);
|
||||
TaxonomyWriter tw2 = new LuceneTaxonomyWriter(indexDir);
|
||||
DirectoryTaxonomyWriter.unlock(indexDir);
|
||||
TaxonomyWriter tw2 = new DirectoryTaxonomyWriter(indexDir);
|
||||
tw2.addCategory(new CategoryPath("hey"));
|
||||
tw2.close();
|
||||
// See that the writer indeed wrote:
|
||||
|
@ -1054,7 +1054,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterCheckPaths() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomyCheckPaths(tw);
|
||||
// Also check TaxonomyWriter.getSize() - see that the taxonomy's size
|
||||
// is what we expect it to be.
|
||||
|
@ -1073,14 +1073,14 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
|||
@Test
|
||||
public void testWriterCheckPaths2() throws Exception {
|
||||
Directory indexDir = newDirectory();
|
||||
TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
|
||||
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
fillTaxonomy(tw);
|
||||
checkPaths(tw);
|
||||
fillTaxonomy(tw);
|
||||
checkPaths(tw);
|
||||
tw.close();
|
||||
|
||||
tw = new LuceneTaxonomyWriter(indexDir);
|
||||
tw = new DirectoryTaxonomyWriter(indexDir);
|
||||
checkPaths(tw);
|
||||
fillTaxonomy(tw);
|
||||
checkPaths(tw);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -10,11 +10,11 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.DiskOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.MemoryOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.OrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.DiskOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.MemoryOrdinalMap;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -38,16 +38,16 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
@Test
|
||||
public void test1() throws Exception {
|
||||
Directory dir1 = newDirectory();
|
||||
LuceneTaxonomyWriter tw1 = new LuceneTaxonomyWriter(dir1);
|
||||
DirectoryTaxonomyWriter tw1 = new DirectoryTaxonomyWriter(dir1);
|
||||
tw1.addCategory(new CategoryPath("Author", "Mark Twain"));
|
||||
tw1.addCategory(new CategoryPath("Animals", "Dog"));
|
||||
Directory dir2 = newDirectory();
|
||||
LuceneTaxonomyWriter tw2 = new LuceneTaxonomyWriter(dir2);
|
||||
DirectoryTaxonomyWriter tw2 = new DirectoryTaxonomyWriter(dir2);
|
||||
tw2.addCategory(new CategoryPath("Author", "Rob Pike"));
|
||||
tw2.addCategory(new CategoryPath("Aardvarks", "Bob"));
|
||||
tw2.close();
|
||||
Directory dir3 = newDirectory();
|
||||
LuceneTaxonomyWriter tw3 = new LuceneTaxonomyWriter(dir3);
|
||||
DirectoryTaxonomyWriter tw3 = new DirectoryTaxonomyWriter(dir3);
|
||||
tw3.addCategory(new CategoryPath("Author", "Zebra Smith"));
|
||||
tw3.addCategory(new CategoryPath("Aardvarks", "Bob"));
|
||||
tw3.addCategory(new CategoryPath("Aardvarks", "Aaron"));
|
||||
|
@ -60,7 +60,7 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
tw1.addTaxonomies(new Directory[] { dir2, dir3 }, maps);
|
||||
tw1.close();
|
||||
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dir1);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dir1);
|
||||
|
||||
// Test that the merged taxonomy now contains what we expect:
|
||||
// First all the categories of the original taxonomy, in their original order:
|
||||
|
@ -132,8 +132,8 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
for (int i=0; i<ntaxonomies; i++) {
|
||||
dirs[i] = newDirectory();
|
||||
copydirs[i] = newDirectory();
|
||||
LuceneTaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[i]);
|
||||
LuceneTaxonomyWriter copytw = new LuceneTaxonomyWriter(copydirs[i]);
|
||||
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[i]);
|
||||
DirectoryTaxonomyWriter copytw = new DirectoryTaxonomyWriter(copydirs[i]);
|
||||
for (int j=0; j<ncats; j++) {
|
||||
String cat = Integer.toString(random.nextInt(range));
|
||||
tw.addCategory(new CategoryPath("a",cat));
|
||||
|
@ -144,7 +144,7 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
copytw.close();
|
||||
}
|
||||
|
||||
LuceneTaxonomyWriter tw = new LuceneTaxonomyWriter(dirs[0]);
|
||||
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(dirs[0]);
|
||||
Directory otherdirs[] = new Directory[ntaxonomies-1];
|
||||
System.arraycopy(dirs, 1, otherdirs, 0, ntaxonomies-1);
|
||||
|
||||
|
@ -168,8 +168,8 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
// Check that all original categories in the main taxonomy remain in
|
||||
// unchanged, and the rest of the taxonomies are completely unchanged.
|
||||
for (int i=0; i<ntaxonomies; i++) {
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[i]);
|
||||
TaxonomyReader copytr = new LuceneTaxonomyReader(copydirs[i]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[i]);
|
||||
TaxonomyReader copytr = new DirectoryTaxonomyReader(copydirs[i]);
|
||||
if (i==0) {
|
||||
assertTrue(tr.getSize() >= copytr.getSize());
|
||||
} else {
|
||||
|
@ -188,8 +188,8 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
// Check that all the new categories in the main taxonomy are in
|
||||
// lexicographic order. This isn't a requirement of our API, but happens
|
||||
// this way in our current implementation.
|
||||
TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0]);
|
||||
TaxonomyReader copytr = new LuceneTaxonomyReader(copydirs[0]);
|
||||
TaxonomyReader tr = new DirectoryTaxonomyReader(dirs[0]);
|
||||
TaxonomyReader copytr = new DirectoryTaxonomyReader(copydirs[0]);
|
||||
if (tr.getSize() > copytr.getSize()) {
|
||||
String prev = tr.getPath(copytr.getSize()).toString();
|
||||
for (int j=copytr.getSize()+1; j<tr.getSize(); j++) {
|
||||
|
@ -204,9 +204,9 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
|
||||
// Check that all the categories from other taxonomies exist in the new
|
||||
// taxonomy.
|
||||
TaxonomyReader main = new LuceneTaxonomyReader(dirs[0]);
|
||||
TaxonomyReader main = new DirectoryTaxonomyReader(dirs[0]);
|
||||
for (int i=1; i<ntaxonomies; i++) {
|
||||
TaxonomyReader other = new LuceneTaxonomyReader(dirs[i]);
|
||||
TaxonomyReader other = new DirectoryTaxonomyReader(dirs[i]);
|
||||
for (int j=0; j<other.getSize(); j++) {
|
||||
int otherord = main.getOrdinal(other.getPath(j));
|
||||
assertTrue(otherord != TaxonomyReader.INVALID_ORDINAL);
|
||||
|
@ -218,7 +218,7 @@ public class TestAddTaxonomies extends LuceneTestCase {
|
|||
// one of the added taxonomies.
|
||||
TaxonomyReader[] others = new TaxonomyReader[ntaxonomies-1];
|
||||
for (int i=1; i<ntaxonomies; i++) {
|
||||
others[i-1] = new LuceneTaxonomyReader(dirs[i]);
|
||||
others[i-1] = new DirectoryTaxonomyReader(dirs[i]);
|
||||
}
|
||||
for (int j=oldsize; j<main.getSize(); j++) {
|
||||
boolean found=false;
|
|
@ -1,6 +1,8 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
@ -23,16 +25,16 @@ import org.junit.Test;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class TestLuceneTaxonomyReader extends LuceneTestCase {
|
||||
public class TestDirectoryTaxonomyReader extends LuceneTestCase {
|
||||
|
||||
@Test
|
||||
public void testCloseAfterIncRef() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter ltw = new LuceneTaxonomyWriter(dir);
|
||||
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir);
|
||||
ltw.addCategory(new CategoryPath("a"));
|
||||
ltw.close();
|
||||
|
||||
LuceneTaxonomyReader ltr = new LuceneTaxonomyReader(dir);
|
||||
DirectoryTaxonomyReader ltr = new DirectoryTaxonomyReader(dir);
|
||||
ltr.incRef();
|
||||
ltr.close();
|
||||
|
||||
|
@ -46,11 +48,11 @@ public class TestLuceneTaxonomyReader extends LuceneTestCase {
|
|||
@Test
|
||||
public void testCloseTwice() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter ltw = new LuceneTaxonomyWriter(dir);
|
||||
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir);
|
||||
ltw.addCategory(new CategoryPath("a"));
|
||||
ltw.close();
|
||||
|
||||
LuceneTaxonomyReader ltr = new LuceneTaxonomyReader(dir);
|
||||
DirectoryTaxonomyReader ltr = new DirectoryTaxonomyReader(dir);
|
||||
ltr.close();
|
||||
ltr.close(); // no exception should be thrown
|
||||
|
||||
|
@ -60,11 +62,11 @@ public class TestLuceneTaxonomyReader extends LuceneTestCase {
|
|||
@Test
|
||||
public void testAlreadyClosed() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter ltw = new LuceneTaxonomyWriter(dir);
|
||||
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir);
|
||||
ltw.addCategory(new CategoryPath("a"));
|
||||
ltw.close();
|
||||
|
||||
LuceneTaxonomyReader ltr = new LuceneTaxonomyReader(dir);
|
||||
DirectoryTaxonomyReader ltr = new DirectoryTaxonomyReader(dir);
|
||||
ltr.close();
|
||||
try {
|
||||
ltr.getSize();
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -10,7 +10,7 @@ import org.junit.Test;
|
|||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.writercache.TaxonomyWriterCache;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import org.apache.lucene.facet.taxonomy.writercache.TaxonomyWriterCache;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class TestLuceneTaxonomyWriter extends LuceneTestCase {
|
||||
public class TestDirectoryTaxonomyWriter extends LuceneTestCase {
|
||||
|
||||
// A No-Op TaxonomyWriterCache which always discards all given categories, and
|
||||
// always returns true in put(), to indicate some cache entries were cleared.
|
||||
|
@ -52,7 +52,7 @@ public class TestLuceneTaxonomyWriter extends LuceneTestCase {
|
|||
// Verifies that nothing is committed to the underlying Directory, if
|
||||
// commit() wasn't called.
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter ltw = new LuceneTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
|
||||
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
|
||||
assertFalse(IndexReader.indexExists(dir));
|
||||
ltw.commit(); // first commit, so that an index will be created
|
||||
ltw.addCategory(new CategoryPath("a"));
|
||||
|
@ -68,7 +68,7 @@ public class TestLuceneTaxonomyWriter extends LuceneTestCase {
|
|||
public void testCommitUserData() throws Exception {
|
||||
// Verifies that committed data is retrievable
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter ltw = new LuceneTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
|
||||
DirectoryTaxonomyWriter ltw = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, new NoOpCache());
|
||||
assertFalse(IndexReader.indexExists(dir));
|
||||
ltw.commit(); // first commit, so that an index will be created
|
||||
ltw.addCategory(new CategoryPath("a"));
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.facet.taxonomy.lucene;
|
||||
package org.apache.lucene.facet.taxonomy.directory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
@ -18,8 +18,8 @@ import org.apache.lucene.util.LuceneTestCase;
|
|||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.analysis.MockTokenizer;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
|
||||
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -51,7 +51,7 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
public void testLeaks() throws Exception {
|
||||
LeakChecker checker = new LeakChecker();
|
||||
Directory dir = newDirectory();
|
||||
LuceneTaxonomyWriter tw = checker.openWriter(dir);
|
||||
DirectoryTaxonomyWriter tw = checker.openWriter(dir);
|
||||
tw.close();
|
||||
assertEquals(0, checker.nopen());
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
tw.close();
|
||||
assertEquals(0, checker.nopen());
|
||||
|
||||
LuceneTaxonomyReader tr = checker.openReader(dir);
|
||||
DirectoryTaxonomyReader tr = checker.openReader(dir);
|
||||
tr.getPath(1);
|
||||
tr.refresh();
|
||||
tr.close();
|
||||
|
@ -100,11 +100,11 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
|
||||
LeakChecker() { }
|
||||
|
||||
public LuceneTaxonomyWriter openWriter(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
public DirectoryTaxonomyWriter openWriter(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
return new InstrumentedTaxonomyWriter(dir);
|
||||
}
|
||||
|
||||
public LuceneTaxonomyReader openReader(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
public DirectoryTaxonomyReader openReader(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
return new InstrumentedTaxonomyReader(dir);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private class InstrumentedTaxonomyWriter extends LuceneTaxonomyWriter {
|
||||
private class InstrumentedTaxonomyWriter extends DirectoryTaxonomyWriter {
|
||||
public InstrumentedTaxonomyWriter(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
super(dir);
|
||||
}
|
||||
|
@ -130,8 +130,7 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
return new InstrumentedIndexReader(super.openReader());
|
||||
}
|
||||
@Override
|
||||
protected void openLuceneIndex (Directory directory, OpenMode openMode)
|
||||
throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
protected void openIndexWriter (Directory directory, OpenMode openMode) throws IOException {
|
||||
indexWriter = new InstrumentedIndexWriter(directory,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.KEYWORD, false))
|
||||
.setOpenMode(openMode));
|
||||
|
@ -139,7 +138,7 @@ public class TestIndexClose extends LuceneTestCase {
|
|||
|
||||
}
|
||||
|
||||
private class InstrumentedTaxonomyReader extends LuceneTaxonomyReader {
|
||||
private class InstrumentedTaxonomyReader extends DirectoryTaxonomyReader {
|
||||
public InstrumentedTaxonomyReader(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
|
||||
super(dir);
|
||||
}
|
Loading…
Reference in New Issue