You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2011/11/03 07:28:26 UTC
svn commit: r1196965 [2/2] - in
/lucene/dev/branches/branch_3x/lucene/contrib: ./
benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ facet/docs/
facet/src/examples/org/apache/lucene/facet/example/adaptive/
facet/src/examples/org/apache/lucene...
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java?rev=1196965&r1=1196964&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetRequestTest.java Thu Nov 3 06:28:24 2011
@@ -9,7 +9,7 @@ import org.apache.lucene.util.LuceneTest
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 Lu
// 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 Lu
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());
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java?rev=1196965&r1=1196964&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java Thu Nov 3 06:28:24 2011
@@ -8,8 +8,8 @@ import org.apache.lucene.facet.index.par
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 exten
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 exten
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();
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java?rev=1196965&r1=1196964&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java Thu Nov 3 06:28:24 2011
@@ -32,8 +32,8 @@ import org.apache.lucene.facet.search.re
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 MultiIteratorsPerCLParamsTe
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 MultiIteratorsPerCLParamsTe
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)
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java?rev=1196965&r1=1196964&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java Thu Nov 3 06:28:24 2011
@@ -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 extend
@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 extend
@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 extend
@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 extend
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 extend
// 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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
@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 extend
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 extend
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 extend
@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 extend
@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 extend
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 extend
@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 extend
@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);
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomies.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomies.java?rev=1196965&r1=1196939&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomies.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomies.java Thu Nov 3 06:28:24 2011
@@ -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.LuceneTest
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 L
@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 L
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 L
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 L
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 L
// 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 L
// 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 L
// 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 L
// 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;
Copied: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java (from r1196939, lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyReader.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java?p2=lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java&p1=lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyReader.java&r1=1196939&r2=1196965&rev=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyReader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java Thu Nov 3 06:28:24 2011
@@ -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 ex
@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 ex
@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();
Copied: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java (from r1196939, lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyWriter.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java?p2=lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java&p1=lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyWriter.java&r1=1196939&r2=1196965&rev=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/lucene/TestLuceneTaxonomyWriter.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java Thu Nov 3 06:28:24 2011
@@ -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.
* 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 ex
// 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 ex
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"));
Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java?rev=1196965&r1=1196939&r2=1196965&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java Thu Nov 3 06:28:24 2011
@@ -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.LuceneTest
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 Luce
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 Luce
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 Luce
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 Luce
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 Luce
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 Luce
}
- private class InstrumentedTaxonomyReader extends LuceneTaxonomyReader {
+ private class InstrumentedTaxonomyReader extends DirectoryTaxonomyReader {
public InstrumentedTaxonomyReader(Directory dir) throws CorruptIndexException, LockObtainFailedException, IOException {
super(dir);
}
@@ -154,20 +153,21 @@ public class TestIndexClose extends Luce
int mynum;
public InstrumentedIndexReader(IndexReader in) {
super(in);
- this.in = in;
mynum = ireader++;
openReaders.add(mynum);
// System.err.println("opened "+mynum);
}
+
@Override
- public synchronized IndexReader reopen() throws CorruptIndexException, IOException {
- IndexReader n = in.reopen();
- if (n==in) {
- return this;
+ protected IndexReader doOpenIfChanged() throws CorruptIndexException,
+ IOException {
+ IndexReader n = IndexReader.openIfChanged(in);
+ if (n == null) {
+ return null;
}
return new InstrumentedIndexReader(n);
}
-
+
// Unfortunately, IndexReader.close() is marked final so we can't
// change it! Fortunately, close() calls (if the object wasn't
// already closed) doClose() so we can override it to do our thing -