You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2013/01/18 19:31:23 UTC

svn commit: r1435287 [12/41] - in /lucene/dev/branches/LUCENE-2878: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/analysis/icu/ dev-tools/maven/ dev-tools/maven/lucene/benchmark/ dev-tools/maven/solr/ dev-tools/...

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java Fri Jan 18 18:30:54 2013
@@ -189,8 +189,7 @@ public class TestCachingWrapperFilter ex
 
     final Filter startFilter = new QueryWrapperFilter(new TermQuery(new Term("id", "1")));
 
-    // force cache to regenerate after deletions:
-    CachingWrapperFilter filter = new CachingWrapperFilter(startFilter, true);
+    CachingWrapperFilter filter = new CachingWrapperFilter(startFilter);
 
     docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
 
@@ -231,9 +230,8 @@ public class TestCachingWrapperFilter ex
     docs = searcher.search(new MatchAllDocsQuery(), filter, 1);
     assertEquals("[query + filter] Should *not* find a hit...", 0, docs.totalHits);
 
-    // cache miss, because we asked CWF to recache when
-    // deletes changed:
-    assertEquals(missCount+1, filter.missCount);
+    // cache hit
+    assertEquals(missCount, filter.missCount);
     docs = searcher.search(constantScore, 1);
     assertEquals("[just filter] Should *not* find a hit...", 0, docs.totalHits);
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestMultiThreadTermVectors.java Fri Jan 18 18:30:54 2013
@@ -145,6 +145,7 @@ class MultiThreadTermVectorsReader imple
     return t.isAlive();
   }
   
+  @Override
   public void run() {
       try {
         // run the test 100 times

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestNRTManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestNRTManager.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestNRTManager.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestNRTManager.java Fri Jan 18 18:30:54 2013
@@ -32,7 +32,7 @@ import org.apache.lucene.index.IndexDocu
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.NoMergePolicy;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.ThreadedIndexingAndSearchingTestCase;
@@ -295,6 +295,7 @@ public class TestNRTManager extends Thre
    */
   public void testThreadStarvationNoDeleteNRTReader() throws IOException, InterruptedException {
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+    conf.setMergePolicy(random().nextBoolean() ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES);
     Directory d = newDirectory();
     final CountDownLatch latch = new CountDownLatch(1);
     final CountDownLatch signal = new CountDownLatch(1);
@@ -308,6 +309,7 @@ public class TestNRTManager extends Thre
     manager.maybeRefresh();
     assertFalse(gen < manager.getCurrentSearchingGen());
     Thread t = new Thread() {
+      @Override
       public void run() {
         try {
           signal.await();
@@ -341,6 +343,7 @@ public class TestNRTManager extends Thre
     
     final AtomicBoolean finished = new AtomicBoolean(false);
     Thread waiter = new Thread() {
+      @Override
       public void run() {
         manager.waitForGeneration(lastGen);
         finished.set(true);
@@ -373,6 +376,7 @@ public class TestNRTManager extends Thre
 
     }
 
+    @Override
     public void updateDocument(Term term,
         IndexDocument doc, Analyzer analyzer)
         throws IOException {
@@ -411,4 +415,25 @@ public class TestNRTManager extends Thre
     other.close();
     dir.close();
   }
+
+  public void testListenerCalled() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
+    final AtomicBoolean afterRefreshCalled = new AtomicBoolean(false);
+    NRTManager sm = new NRTManager(new NRTManager.TrackingIndexWriter(iw),new SearcherFactory());
+    sm.addListener(new ReferenceManager.RefreshListener() {
+      @Override
+      public void afterRefresh() {
+        afterRefreshCalled.set(true);
+      }
+    });
+    iw.addDocument(new Document());
+    iw.commit();
+    assertFalse(afterRefreshCalled.get());
+    sm.maybeRefreshBlocking();
+    assertTrue(afterRefreshCalled.get());
+    sm.close();
+    iw.close();
+    dir.close();
+  }
 }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestRegexpQuery.java Fri Jan 18 18:30:54 2013
@@ -102,6 +102,7 @@ public class TestRegexpQuery extends Luc
           BasicAutomata.makeString("brown"),
           BasicAutomata.makeString("bob")));
       
+      @Override
       public Automaton getAutomaton(String name) {
         if (name.equals("quickBrown")) return quickBrownAutomaton;
         else return null;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSearcherManager.java Fri Jan 18 18:30:54 2013
@@ -324,6 +324,27 @@ public class TestSearcherManager extends
     dir.close();
   }
 
+  public void testListenerCalled() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
+    final AtomicBoolean afterRefreshCalled = new AtomicBoolean(false);
+    SearcherManager sm = new SearcherManager(iw, false, new SearcherFactory());
+    sm.addListener(new ReferenceManager.RefreshListener() {
+      @Override
+      public void afterRefresh() {
+        afterRefreshCalled.set(true);
+      }
+    });
+    iw.addDocument(new Document());
+    iw.commit();
+    assertFalse(afterRefreshCalled.get());
+    sm.maybeRefreshBlocking();
+    assertTrue(afterRefreshCalled.get());
+    sm.close();
+    iw.close();
+    dir.close();
+  }
+
   public void testEvilSearcherFactory() throws Exception {
     final Random random = random();
     final Directory dir = newDirectory();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java Fri Jan 18 18:30:54 2013
@@ -40,7 +40,9 @@ import org.apache.lucene.document.Docume
 public class TestSimilarity extends LuceneTestCase {
   
   public static class SimpleSimilarity extends DefaultSimilarity {
+    @Override
     public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
+    @Override
     public float coord(int overlap, int maxOverlap) { return 1.0f; }
     @Override public float lengthNorm(FieldInvertState state) { return state.getBoost(); }
     @Override public float tf(float freq) { return freq; }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java Fri Jan 18 18:30:54 2013
@@ -95,6 +95,7 @@ public class TestSimilarityProvider exte
     private Similarity sim1 = new Sim1();
     private Similarity sim2 = new Sim2();
     
+    @Override
     public Similarity get(String field) {
       if (field.equals("foo")) {
         return sim1;
@@ -106,10 +107,12 @@ public class TestSimilarityProvider exte
   
   private class Sim1 extends TFIDFSimilarity {
     
+    @Override
     public float coord(int overlap, int maxOverlap) {
       return 1f;
     }
 
+    @Override
     public float queryNorm(float sumOfSquaredWeights) {
       return 1f;
     }
@@ -142,10 +145,12 @@ public class TestSimilarityProvider exte
   
   private class Sim2 extends TFIDFSimilarity {
     
+    @Override
     public float coord(int overlap, int maxOverlap) {
       return 1f;
     }
 
+    @Override
     public float queryNorm(float sumOfSquaredWeights) {
       return 1f;
     }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSort.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestSort.java Fri Jan 18 18:30:54 2013
@@ -577,6 +577,7 @@ public class TestSort extends LuceneTest
 
 
     sort.setSort (new SortField ("parser", new FieldCache.IntParser(){
+      @Override
       public final int parseInt(final BytesRef term) {
         return (term.bytes[term.offset]-'A') * 123456;
       }
@@ -586,6 +587,7 @@ public class TestSort extends LuceneTest
     fc.purgeAllCaches();
 
     sort.setSort (new SortField ("parser", new FieldCache.FloatParser(){
+      @Override
       public final float parseFloat(final BytesRef term) {
         return (float) Math.sqrt( term.bytes[term.offset] );
       }
@@ -595,6 +597,7 @@ public class TestSort extends LuceneTest
     fc.purgeAllCaches();
 
     sort.setSort (new SortField ("parser", new FieldCache.LongParser(){
+      @Override
       public final long parseLong(final BytesRef term) {
         return (term.bytes[term.offset]-'A') * 1234567890L;
       }
@@ -604,6 +607,7 @@ public class TestSort extends LuceneTest
     fc.purgeAllCaches();
 
     sort.setSort (new SortField ("parser", new FieldCache.DoubleParser(){
+      @Override
       public final double parseDouble(final BytesRef term) {
         return Math.pow( term.bytes[term.offset], (term.bytes[term.offset]-'A') );
       }
@@ -613,6 +617,7 @@ public class TestSort extends LuceneTest
     fc.purgeAllCaches();
 
     sort.setSort (new SortField ("parser", new FieldCache.ByteParser(){
+      @Override
       public final byte parseByte(final BytesRef term) {
         return (byte) (term.bytes[term.offset]-'A');
       }
@@ -622,6 +627,7 @@ public class TestSort extends LuceneTest
     fc.purgeAllCaches();
 
     sort.setSort (new SortField ("parser", new FieldCache.ShortParser(){
+      @Override
       public final short parseShort(final BytesRef term) {
         return (short) (term.bytes[term.offset]-'A');
       }
@@ -698,6 +704,7 @@ public class TestSort extends LuceneTest
     }
 
     private static final FieldCache.IntParser testIntParser = new FieldCache.IntParser() {
+      @Override
       public final int parseInt(final BytesRef term) {
         return (term.bytes[term.offset]-'A') * 123456;
       }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Fri Jan 18 18:30:54 2013
@@ -306,10 +306,12 @@ public class TestPayloadNearQuery extend
 
   static class BoostingSimilarity extends DefaultSimilarity {
 
+    @Override
     public float queryNorm(float sumOfSquaredWeights) {
       return 1.0f;
     }
     
+    @Override
     public float coord(int overlap, int maxOverlap) {
       return 1.0f;
     }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java Fri Jan 18 18:30:54 2013
@@ -295,10 +295,12 @@ public class TestPayloadTermQuery extend
 
   static class BoostingSimilarity extends DefaultSimilarity {
 
+    @Override
     public float queryNorm(float sumOfSquaredWeights) {
       return 1;
     }
     
+    @Override
     public float coord(int overlap, int maxOverlap) {
       return 1;
     }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestDirectory.java Fri Jan 18 18:30:54 2013
@@ -65,6 +65,7 @@ public class TestDirectory extends Lucen
         this.name = name;
       }
       
+      @Override
       public void run() {
         for (int i = 0; i < 3000; i++) {
           String fileName = this.name + i;
@@ -87,6 +88,7 @@ public class TestDirectory extends Lucen
         this.name = name;
       }
       
+      @Override
       public void run() {
         for (int i = 0; i < 10000; i++) {
           try {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java Fri Jan 18 18:30:54 2013
@@ -17,6 +17,7 @@ package org.apache.lucene.store;
  * limitations under the License.
  */
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
@@ -84,15 +85,25 @@ public class TestFileSwitchDirectory ext
   }
   
   private Directory newFSSwitchDirectory(Set<String> primaryExtensions) throws IOException {
-    Directory a = new SimpleFSDirectory(_TestUtil.getTempDir("foo"));
-    Directory b = new SimpleFSDirectory(_TestUtil.getTempDir("bar"));
+    File primDir = _TestUtil.getTempDir("foo");
+    File secondDir = _TestUtil.getTempDir("bar");
+    return newFSSwitchDirectory(primDir, secondDir, primaryExtensions);
+  }
+
+  private Directory newFSSwitchDirectory(File aDir, File bDir, Set<String> primaryExtensions) throws IOException {
+    Directory a = new SimpleFSDirectory(aDir);
+    Directory b = new SimpleFSDirectory(bDir);
     FileSwitchDirectory switchDir = new FileSwitchDirectory(primaryExtensions, a, b, true);
     return new MockDirectoryWrapper(random(), switchDir);
   }
   
   // LUCENE-3380 -- make sure we get exception if the directory really does not exist.
   public void testNoDir() throws Throwable {
-    Directory dir = newFSSwitchDirectory(Collections.<String>emptySet());
+    File primDir = _TestUtil.getTempDir("foo");
+    File secondDir = _TestUtil.getTempDir("bar");
+    _TestUtil.rmDir(primDir);
+    _TestUtil.rmDir(secondDir);
+    Directory dir = newFSSwitchDirectory(primDir, secondDir, Collections.<String>emptySet());
     try {
       DirectoryReader.open(dir);
       fail("did not hit expected exception");

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java Fri Jan 18 18:30:54 2013
@@ -123,7 +123,9 @@ public class TestNRTCachingDirectory ext
   
   // LUCENE-3382 -- make sure we get exception if the directory really does not exist.
   public void testNoDir() throws Throwable {
-    Directory dir = new NRTCachingDirectory(newFSDirectory(_TestUtil.getTempDir("doesnotexist")), 2.0, 25.0);
+    File tempDir = _TestUtil.getTempDir("doesnotexist");
+    _TestUtil.rmDir(tempDir);
+    Directory dir = new NRTCachingDirectory(newFSDirectory(tempDir), 2.0, 25.0);
     try {
       DirectoryReader.open(dir);
       fail("did not hit expected exception");

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestArrayUtil.java Fri Jan 18 18:30:54 2013
@@ -211,6 +211,7 @@ public class TestArrayUtil extends Lucen
       this.order = order;
     }
     
+    @Override
     public int compareTo(Item other) {
       return this.order - other.order;
     }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestCharsRef.java Fri Jan 18 18:30:54 2013
@@ -116,11 +116,28 @@ public class TestCharsRef extends Lucene
   }
   
   // LUCENE-3590: fix off-by-one in subsequence, and fully obey interface
+  // LUCENE-4671: fix subSequence
   public void testCharSequenceSubSequence() {
-    CharSequence c = new CharsRef("abc");
+    CharSequence sequences[] =  {
+        new CharsRef("abc"),
+        new CharsRef("0abc".toCharArray(), 1, 3),
+        new CharsRef("abc0".toCharArray(), 0, 3),
+        new CharsRef("0abc0".toCharArray(), 1, 3)
+    };
+    
+    for (CharSequence c : sequences) {
+      doTestSequence(c);
+    }
+  }
+    
+  private void doTestSequence(CharSequence c) {
     
     // slice
     assertEquals("a", c.subSequence(0, 1).toString());
+    // mid subsequence
+    assertEquals("b", c.subSequence(1, 2).toString());
+    // end subsequence
+    assertEquals("bc", c.subSequence(1, 3).toString());
     // empty subsequence
     assertEquals("", c.subSequence(0, 0).toString());
     

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestFixedBitSet.java Fri Jan 18 18:30:54 2013
@@ -265,7 +265,18 @@ public class TestFixedBitSet extends Luc
   }
   
   private FixedBitSet makeFixedBitSet(int[] a, int numBits) {
-    FixedBitSet bs = new FixedBitSet(numBits);
+    FixedBitSet bs;
+    if (random().nextBoolean()) {
+      int bits2words = FixedBitSet.bits2words(numBits);
+      long[] words = new long[bits2words + random().nextInt(100)];
+      for (int i = bits2words; i < words.length; i++) {
+        words[i] = random().nextLong();
+      }
+      bs = new FixedBitSet(words, numBits);
+
+    } else {
+      bs = new FixedBitSet(numBits);
+    }
     for (int e: a) {
       bs.set(e);
     }
@@ -291,6 +302,23 @@ public class TestFixedBitSet extends Luc
     checkPrevSetBitArray(new int[] {0}, 1);
     checkPrevSetBitArray(new int[] {0,2}, 3);
   }
+  
+  
+  private void checkNextSetBitArray(int [] a, int numBits) {
+    FixedBitSet obs = makeFixedBitSet(a, numBits);
+    BitSet bs = makeBitSet(a);
+    doNextSetBit(bs, obs);
+  }
+  
+  public void testNextBitSet() {
+    int[] setBits = new int[0+random().nextInt(1000)];
+    for (int i = 0; i < setBits.length; i++) {
+      setBits[i] = random().nextInt(setBits.length);
+    }
+    checkNextSetBitArray(setBits, setBits.length + random().nextInt(10));
+    
+    checkNextSetBitArray(new int[0], setBits.length + random().nextInt(10));
+  }
 }
 
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java Fri Jan 18 18:30:54 2013
@@ -45,9 +45,22 @@ public class TestMaxFailuresRule extends
   }
 
   public static class Nested extends WithNestedTests.AbstractNestedTest {
-    @Repeat(iterations = 500)
+    public static final int TOTAL_ITERS = 500;
+    public static final int DESIRED_FAILURES = TOTAL_ITERS / 10;
+    private int numFails = 0;
+    private int numIters = 0;
+
+    @Repeat(iterations = TOTAL_ITERS)
     public void testFailSometimes() {
-      assertFalse(random().nextInt(5) == 0);
+      numIters++;
+      boolean fail = random().nextInt(5) == 0;
+      if (fail) numFails++;
+      // some seeds are really lucky ... so cheat.
+      if (numFails < DESIRED_FAILURES && 
+          DESIRED_FAILURES <= TOTAL_ITERS - numIters) {
+        fail = true;
+      }
+      assertFalse(fail);
     }
   }
 
@@ -95,6 +108,7 @@ public class TestMaxFailuresRule extends
       // resulting from ignored tests.
       Assert.assertTrue(results.toString(), 
           results.toString().matches("(S*F){2}A+"));
+
     } finally {
       LuceneTestCase.ignoreAfterMaxFailures.maxFailures = maxFailures;
       LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = failuresSoFar;

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java Fri Jan 18 18:30:54 2013
@@ -177,6 +177,7 @@ public class TestWeakIdentityMap extends
       for (int t = 0; t < threadCount; t++) {
         final Random rnd = new Random(random().nextLong());
         exec.execute(new Runnable() {
+          @Override
           public void run() {
             final int count = atLeast(rnd, 10000);
             for (int i = 0; i < count; i++) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java Fri Jan 18 18:30:54 2013
@@ -310,7 +310,7 @@ public class TestFSTs extends LuceneTest
 
     final boolean doRewrite = random().nextBoolean();
 
-    Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs, null, doRewrite);
+    Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs, null, doRewrite, PackedInts.DEFAULT, true, 15);
 
     boolean storeOrd = random().nextBoolean();
     if (VERBOSE) {
@@ -369,61 +369,52 @@ public class TestFSTs extends LuceneTest
 
       if (ord > 0) {
         final Random random = new Random(random().nextLong());
-        for(int rewriteIter=0;rewriteIter<2;rewriteIter++) {
-          if (rewriteIter == 1) {
-            if (doRewrite) {
-              // Verify again, with packed FST:
-              fst = fst.pack(_TestUtil.nextInt(random, 1, 10), _TestUtil.nextInt(random, 0, 10000000), random.nextFloat());
-            } else {
-              break;
-            }
+        // Now confirm BytesRefFSTEnum and TermsEnum act the
+        // same:
+        final BytesRefFSTEnum<Long> fstEnum = new BytesRefFSTEnum<Long>(fst);
+        int num = atLeast(1000);
+        for(int iter=0;iter<num;iter++) {
+          final BytesRef randomTerm = new BytesRef(getRandomString(random));
+          
+          if (VERBOSE) {
+            System.out.println("TEST: seek non-exist " + randomTerm.utf8ToString() + " " + randomTerm);
           }
-          // Now confirm BytesRefFSTEnum and TermsEnum act the
-          // same:
-          final BytesRefFSTEnum<Long> fstEnum = new BytesRefFSTEnum<Long>(fst);
-          int num = atLeast(1000);
-          for(int iter=0;iter<num;iter++) {
-            final BytesRef randomTerm = new BytesRef(getRandomString(random));
-        
-            if (VERBOSE) {
-              System.out.println("TEST: seek non-exist " + randomTerm.utf8ToString() + " " + randomTerm);
-            }
-
-            final TermsEnum.SeekStatus seekResult = termsEnum.seekCeil(randomTerm);
-            final InputOutput<Long> fstSeekResult = fstEnum.seekCeil(randomTerm);
-
-            if (seekResult == TermsEnum.SeekStatus.END) {
-              assertNull("got " + (fstSeekResult == null ? "null" : fstSeekResult.input.utf8ToString()) + " but expected null", fstSeekResult);
-            } else {
-              assertSame(termsEnum, fstEnum, storeOrd);
-              for(int nextIter=0;nextIter<10;nextIter++) {
+          
+          final TermsEnum.SeekStatus seekResult = termsEnum.seekCeil(randomTerm);
+          final InputOutput<Long> fstSeekResult = fstEnum.seekCeil(randomTerm);
+          
+          if (seekResult == TermsEnum.SeekStatus.END) {
+            assertNull("got " + (fstSeekResult == null ? "null" : fstSeekResult.input.utf8ToString()) + " but expected null", fstSeekResult);
+          } else {
+            assertSame(termsEnum, fstEnum, storeOrd);
+            for(int nextIter=0;nextIter<10;nextIter++) {
+              if (VERBOSE) {
+                System.out.println("TEST: next");
+                if (storeOrd) {
+                  System.out.println("  ord=" + termsEnum.ord());
+                }
+              }
+              if (termsEnum.next() != null) {
                 if (VERBOSE) {
-                  System.out.println("TEST: next");
-                  if (storeOrd) {
-                    System.out.println("  ord=" + termsEnum.ord());
-                  }
+                  System.out.println("  term=" + termsEnum.term().utf8ToString());
                 }
-                if (termsEnum.next() != null) {
-                  if (VERBOSE) {
-                    System.out.println("  term=" + termsEnum.term().utf8ToString());
-                  }
-                  assertNotNull(fstEnum.next());
-                  assertSame(termsEnum, fstEnum, storeOrd);
-                } else {
-                  if (VERBOSE) {
-                    System.out.println("  end!");
-                  }
-                  BytesRefFSTEnum.InputOutput<Long> nextResult = fstEnum.next();
-                  if (nextResult != null) {
-                    System.out.println("expected null but got: input=" + nextResult.input.utf8ToString() + " output=" + outputs.outputToString(nextResult.output));
-                    fail();
-                  }
-                  break;
+                assertNotNull(fstEnum.next());
+                assertSame(termsEnum, fstEnum, storeOrd);
+              } else {
+                if (VERBOSE) {
+                  System.out.println("  end!");
                 }
+                BytesRefFSTEnum.InputOutput<Long> nextResult = fstEnum.next();
+                if (nextResult != null) {
+                  System.out.println("expected null but got: input=" + nextResult.input.utf8ToString() + " output=" + outputs.outputToString(nextResult.output));
+                  fail();
+                }
+                break;
               }
             }
           }
         }
+        
       }
     }
 
@@ -462,8 +453,7 @@ public class TestFSTs extends LuceneTest
       this.outputs = outputs;
       this.doPack = doPack;
 
-      builder = new Builder<T>(inputMode == 0 ? FST.INPUT_TYPE.BYTE1 : FST.INPUT_TYPE.BYTE4, 0, prune, prune == 0, true, Integer.MAX_VALUE, outputs, null, doPack);
-      builder.setAllowArrayArcs(!noArcArrays);
+      builder = new Builder<T>(inputMode == 0 ? FST.INPUT_TYPE.BYTE1 : FST.INPUT_TYPE.BYTE4, 0, prune, prune == 0, true, Integer.MAX_VALUE, outputs, null, doPack, PackedInts.DEFAULT, !noArcArrays, 15);
     }
 
     protected abstract T getOutput(IntsRef input, int ord) throws IOException;
@@ -494,8 +484,13 @@ public class TestFSTs extends LuceneTest
           }
         }
 
+        long tMid = System.currentTimeMillis();
+        System.out.println(((tMid-tStart) / 1000.0) + " sec to add all terms");
+
         assert builder.getTermCount() == ord;
         FST<T> fst = builder.finish();
+        long tEnd = System.currentTimeMillis();
+        System.out.println(((tEnd-tMid) / 1000.0) + " sec to finish/pack");
         if (fst == null) {
           System.out.println("FST was fully pruned!");
           System.exit(0);
@@ -513,12 +508,6 @@ public class TestFSTs extends LuceneTest
           System.out.println("Wrote FST to out.dot");
         }
 
-        if (doPack) {
-          System.out.println("Pack...");
-          fst = fst.pack(4, 100000000, random().nextFloat());
-          System.out.println("New size " + fst.sizeInBytes() + " bytes");
-        }
-        
         Directory dir = FSDirectory.open(new File(dirOut));
         IndexOutput out = dir.createOutput("fst.bin", IOContext.DEFAULT);
         fst.save(out);
@@ -529,6 +518,12 @@ public class TestFSTs extends LuceneTest
           return;
         }
 
+        /*
+        IndexInput in = dir.openInput("fst.bin", IOContext.DEFAULT);
+        fst = new FST<T>(in, outputs);
+        in.close();
+        */
+
         System.out.println("\nNow verify...");
 
         while(true) {
@@ -592,7 +587,7 @@ public class TestFSTs extends LuceneTest
     }
   }
 
-  // java -cp build/classes/test:build/classes/test-framework:build/classes/java:lib/junit-4.10.jar org.apache.lucene.util.fst.TestFSTs /x/tmp/allTerms3.txt out
+  // java -cp ../build/codecs/classes/java:../test-framework/lib/randomizedtesting-runner-2.0.8.jar:../build/core/classes/test:../build/core/classes/test-framework:../build/core/classes/java:../build/test-framework/classes/java:../test-framework/lib/junit-4.10.jar org.apache.lucene.util.fst.TestFSTs /xold/tmp/allTerms3.txt out
   public static void main(String[] args) throws IOException {
     int prune = 0;
     int limit = Integer.MAX_VALUE;
@@ -1038,7 +1033,7 @@ public class TestFSTs extends LuceneTest
         throws IOException {
         if (FST.targetHasArcs(arc)) {
           int childCount = 0;
-          FST.BytesReader fstReader = fst.getBytesReader(0);
+          BytesReader fstReader = fst.getBytesReader();
           for (arc = fst.readFirstTargetArc(arc, arc, fstReader);; 
                arc = fst.readNextArc(arc, fstReader), childCount++)
           {
@@ -1078,7 +1073,7 @@ public class TestFSTs extends LuceneTest
   public void testFinalOutputOnEndState() throws Exception {
     final PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(true);
 
-    final Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE4, 2, 0, true, true, Integer.MAX_VALUE, outputs, null, random().nextBoolean());
+    final Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE4, 2, 0, true, true, Integer.MAX_VALUE, outputs, null, random().nextBoolean(), PackedInts.DEFAULT, true, 15);
     builder.add(Util.toUTF32("stat", new IntsRef()), 17L);
     builder.add(Util.toUTF32("station", new IntsRef()), 10L);
     final FST<Long> fst = builder.finish();
@@ -1093,7 +1088,7 @@ public class TestFSTs extends LuceneTest
   public void testInternalFinalState() throws Exception {
     final PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(true);
     final boolean willRewrite = random().nextBoolean();
-    final Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs, null, willRewrite);
+    final Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs, null, willRewrite, PackedInts.DEFAULT, true, 15);
     builder.add(Util.toIntsRef(new BytesRef("stat"), new IntsRef()), outputs.getNoOutput());
     builder.add(Util.toIntsRef(new BytesRef("station"), new IntsRef()), outputs.getNoOutput());
     final FST<Long> fst = builder.finish();
@@ -1102,13 +1097,11 @@ public class TestFSTs extends LuceneTest
     Util.toDot(fst, w, false, false);
     w.close();
     //System.out.println(w.toString());
-    final String expected;
-    if (willRewrite) {
-      expected = "4 -> 3 [label=\"t\" style=\"bold\"";
-    } else {
-      expected = "8 -> 6 [label=\"t\" style=\"bold\"";
-    }
-    assertTrue(w.toString().indexOf(expected) != -1);
+    
+    // check for accept state at label t
+    assertTrue(w.toString().indexOf("[label=\"t\" style=\"bold\"") != -1);
+    // check for accept state at label n
+    assertTrue(w.toString().indexOf("[label=\"n\" style=\"bold\"") != -1);
   }
 
   // Make sure raw FST can differentiate between final vs
@@ -1118,7 +1111,7 @@ public class TestFSTs extends LuceneTest
     final Long nothing = outputs.getNoOutput();
     final Builder<Long> b = new Builder<Long>(FST.INPUT_TYPE.BYTE1, outputs);
 
-    final FST<Long> fst = new FST<Long>(FST.INPUT_TYPE.BYTE1, outputs, false, PackedInts.COMPACT);
+    final FST<Long> fst = new FST<Long>(FST.INPUT_TYPE.BYTE1, outputs, false, PackedInts.COMPACT, true, 15);
 
     final Builder.UnCompiledNode<Long> rootNode = new Builder.UnCompiledNode<Long>(b, 0);
 
@@ -1175,18 +1168,19 @@ public class TestFSTs extends LuceneTest
     assertEquals(nothing, startArc.nextFinalOutput);
 
     FST.Arc<Long> arc = fst.readFirstTargetArc(startArc, new FST.Arc<Long>(),
-                                               fst.getBytesReader(0));
+                                               fst.getBytesReader());
     assertEquals('a', arc.label);
     assertEquals(17, arc.nextFinalOutput.longValue());
     assertTrue(arc.isFinal());
 
-    arc = fst.readNextArc(arc, fst.getBytesReader(0));
+    arc = fst.readNextArc(arc, fst.getBytesReader());
     assertEquals('b', arc.label);
     assertFalse(arc.isFinal());
     assertEquals(42, arc.output.longValue());
   }
   
   static final Comparator<Long> minLongComparator = new Comparator<Long> () {
+    @Override
     public int compare(Long left, Long right) {
       return left.compareTo(right);
     }  
@@ -1225,6 +1219,7 @@ public class TestFSTs extends LuceneTest
   
   // compares just the weight side of the pair
   static final Comparator<Pair<Long,Long>> minPairWeightComparator = new Comparator<Pair<Long,Long>> () {
+    @Override
     public int compare(Pair<Long,Long> left, Pair<Long,Long> right) {
       return left.output1.compareTo(right.output1);
     }  
@@ -1308,7 +1303,7 @@ public class TestFSTs extends LuceneTest
     //Util.toDot(fst, w, false, false);
     //w.close();
     
-    BytesReader reader = fst.getBytesReader(0);
+    BytesReader reader = fst.getBytesReader();
     
     //System.out.println("testing: " + allPrefixes.size() + " prefixes");
     for (String prefix : allPrefixes) {
@@ -1429,7 +1424,7 @@ public class TestFSTs extends LuceneTest
     //Util.toDot(fst, w, false, false);
     //w.close();
     
-    BytesReader reader = fst.getBytesReader(0);
+    BytesReader reader = fst.getBytesReader();
     
     //System.out.println("testing: " + allPrefixes.size() + " prefixes");
     for (String prefix : allPrefixes) {

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestBeforeAfterOverrides.java Fri Jan 18 18:30:54 2013
@@ -37,6 +37,7 @@ public class TestBeforeAfterOverrides ex
   }
   public static class Before2 extends Before1 {}
   public static class Before3 extends Before2 {
+    @Override
     @Before
     public void before() {}
   }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestExceptionInBeforeClassHooks.java Fri Jan 18 18:30:54 2013
@@ -39,6 +39,7 @@ public class TestExceptionInBeforeClassH
     @BeforeClass
     public static void beforeClass() throws Exception {
       Thread t = new Thread() {
+        @Override
         public void run() {
           throw new RuntimeException("foobar");
         }
@@ -53,6 +54,7 @@ public class TestExceptionInBeforeClassH
   public static class Nested2 extends WithNestedTests.AbstractNestedTest {
     public void test1() throws Exception {
       Thread t = new Thread() {
+        @Override
         public void run() {
           throw new RuntimeException("foobar1");
         }
@@ -63,6 +65,7 @@ public class TestExceptionInBeforeClassH
 
     public void test2() throws Exception {
       Thread t = new Thread() {
+        @Override
         public void run() {
           throw new RuntimeException("foobar2");
         }
@@ -73,6 +76,7 @@ public class TestExceptionInBeforeClassH
     
     public void test3() throws Exception {
       Thread t = new Thread() {
+        @Override
         public void run() {
           throw new RuntimeException("foobar3");
         }
@@ -86,6 +90,7 @@ public class TestExceptionInBeforeClassH
     @Before
     public void runBeforeTest() throws Exception {
       Thread t = new Thread() {
+        @Override
         public void run() {
           throw new RuntimeException("foobar");
         }

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestJUnitRuleOrder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestJUnitRuleOrder.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestJUnitRuleOrder.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestJUnitRuleOrder.java Fri Jan 18 18:30:54 2013
@@ -60,6 +60,7 @@ public class TestJUnitRuleOrder extends 
       @Override
       public Statement apply(final Statement base, Description description) {
         return new Statement() {
+          @Override
           public void evaluate() throws Throwable {
             stack.push("@Rule before");
             base.evaluate();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/junitcompat/TestReproduceMessage.java Fri Jan 18 18:30:54 2013
@@ -52,6 +52,7 @@ public class TestReproduceMessage extend
       @Override
       public Statement apply(final Statement base, Description description) {
         return new Statement() {
+          @Override
           public void evaluate() throws Throwable {
             triggerOn(SorePoint.RULE);
             base.evaluate();

Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java Fri Jan 18 18:30:54 2013
@@ -27,6 +27,8 @@ import java.util.Locale;
 import java.util.Random;
 
 import org.apache.lucene.codecs.CodecUtil;
+import org.apache.lucene.store.ByteArrayDataInput;
+import org.apache.lucene.store.DataInput;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.IndexInput;
@@ -787,4 +789,145 @@ public class TestPackedInts extends Luce
     return true;
   }
 
+  public void testPackedInputOutput() throws IOException {
+    final long[] longs = new long[random().nextInt(8192)];
+    final int[] bitsPerValues = new int[longs.length];
+    final boolean[] skip = new boolean[longs.length];
+    for (int i = 0; i < longs.length; ++i) {
+      final int bpv = RandomInts.randomIntBetween(random(), 1, 64);
+      bitsPerValues[i] = random().nextBoolean() ? bpv : _TestUtil.nextInt(random(), bpv, 64);
+      if (bpv == 64) {
+        longs[i] = random().nextLong();
+      } else {
+        longs[i] = _TestUtil.nextLong(random(), 0, PackedInts.maxValue(bpv));
+      }
+      skip[i] = rarely();
+    }
+
+    final Directory dir = newDirectory();
+    final IndexOutput out = dir.createOutput("out.bin", IOContext.DEFAULT);
+    PackedDataOutput pout = new PackedDataOutput(out);
+    long totalBits = 0;
+    for (int i = 0; i < longs.length; ++i) {
+      pout.writeLong(longs[i], bitsPerValues[i]);
+      totalBits += bitsPerValues[i];
+      if (skip[i]) {
+        pout.flush();
+        totalBits = 8 * (long) Math.ceil((double) totalBits / 8);
+      }
+    }
+    pout.flush();
+    assertEquals((long) Math.ceil((double) totalBits / 8), out.getFilePointer());
+    out.close();
+    final IndexInput in = dir.openInput("out.bin", IOContext.READONCE);
+    final PackedDataInput pin = new PackedDataInput(in);
+    for (int i = 0; i < longs.length; ++i) {
+      assertEquals("" + i, longs[i], pin.readLong(bitsPerValues[i]));
+      if (skip[i]) {
+        pin.skipToNextByte();
+      }
+    }
+    assertEquals((long) Math.ceil((double) totalBits / 8), in.getFilePointer());
+    in.close();
+    dir.close();
+  }
+
+  public void testBlockPackedReaderWriter() throws IOException {
+    final int iters = atLeast(2);
+    for (int iter = 0; iter < iters; ++iter) {
+      final int blockSize = 64 * _TestUtil.nextInt(random(), 1, 1 << 12);
+      final int valueCount = random().nextInt(1 << 18);
+      final long[] values = new long[valueCount];
+      long minValue = 0;
+      int bpv = 0;
+      for (int i = 0; i < valueCount; ++i) {
+        if (i % blockSize == 0) {
+          minValue = rarely() ? random().nextInt(256) : rarely() ? -5 : random().nextLong();
+          bpv = random().nextInt(65);
+        }
+        if (bpv == 0) {
+          values[i] = minValue;
+        } else if (bpv == 64) {
+          values[i] = random().nextLong();
+        } else {
+          values[i] = minValue + _TestUtil.nextLong(random(), 0, (1L << bpv) - 1);
+        }
+      }
+  
+      final Directory dir = newDirectory();
+      final IndexOutput out = dir.createOutput("out.bin", IOContext.DEFAULT);
+      final BlockPackedWriter writer = new BlockPackedWriter(out, blockSize);
+      for (int i = 0; i < valueCount; ++i) {
+        assertEquals(i, writer.ord());
+        writer.add(values[i]);
+      }
+      assertEquals(valueCount, writer.ord());
+      writer.finish();
+      assertEquals(valueCount, writer.ord());
+      final long fp = out.getFilePointer();
+      out.close();
+
+      DataInput in = dir.openInput("out.bin", IOContext.DEFAULT);
+      if (random().nextBoolean()) {
+        byte[] buf = new byte[(int) fp];
+        in.readBytes(buf, 0, (int) fp);
+        ((IndexInput) in).close();
+        in = new ByteArrayDataInput(buf);
+      }
+      final BlockPackedReader reader = new BlockPackedReader(in, PackedInts.VERSION_CURRENT, blockSize, valueCount);
+      for (int i = 0; i < valueCount; ) {
+        if (random().nextBoolean()) {
+          assertEquals("" + i, values[i], reader.next());
+          ++i;
+        } else {
+          final LongsRef nextValues = reader.next(_TestUtil.nextInt(random(), 1, 1024));
+          for (int j = 0; j < nextValues.length; ++j) {
+            assertEquals("" + (i + j), values[i + j], nextValues.longs[nextValues.offset + j]);
+          }
+          i += nextValues.length;
+        }
+        assertEquals(i, reader.ord());
+      }
+      assertEquals(fp, in instanceof ByteArrayDataInput ? ((ByteArrayDataInput) in).getPosition() : ((IndexInput) in).getFilePointer());
+      try {
+        reader.next();
+        assertTrue(false);
+      } catch (IOException e) {
+        // OK
+      }
+
+      if (in instanceof ByteArrayDataInput) {
+        ((ByteArrayDataInput) in).setPosition(0);
+      } else {
+        ((IndexInput) in).seek(0L);
+      }
+      final BlockPackedReader reader2 = new BlockPackedReader(in, PackedInts.VERSION_CURRENT, blockSize, valueCount);
+      int i = 0;
+      while (true) {
+        final int skip = _TestUtil.nextInt(random(), 0, valueCount - i);
+        reader2.skip(skip);
+        i += skip;
+        assertEquals(i, reader2.ord());
+        if (i == valueCount) {
+          break;
+        } else {
+          assertEquals(values[i], reader2.next());
+          ++i;
+        }
+      }
+      assertEquals(fp, in instanceof ByteArrayDataInput ? ((ByteArrayDataInput) in).getPosition() : ((IndexInput) in).getFilePointer());
+      try {
+        reader2.skip(1);
+        assertTrue(false);
+      } catch (IOException e) {
+        // OK
+      }
+
+      if (in instanceof IndexInput) {
+        ((IndexInput) in).close();
+      }
+      dir.close();
+    }
+  }
+
 }

Modified: lucene/dev/branches/LUCENE-2878/lucene/demo/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/demo/build.xml?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/demo/build.xml (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/demo/build.xml Fri Jan 18 18:30:54 2013
@@ -30,10 +30,10 @@
   <target name="init" depends="module-build.init,jar-lucene-core"/>
   
   <path id="classpath">
-	 <pathelement path="${analyzers-common.jar}"/>
+   <pathelement path="${analyzers-common.jar}"/>
    <pathelement path="${queryparser.jar}"/>
    <pathelement path="${lucene-core.jar}"/>
-   <pathelement location="lib/servlet-api-2.4.jar"/>
+   <fileset dir="lib"/>
   </path>
 
   <target name="javadocs" depends="javadocs-analyzers-common,javadocs-queryparser,compile-core">

Modified: lucene/dev/branches/LUCENE-2878/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java Fri Jan 18 18:30:54 2013
@@ -46,7 +46,7 @@ public class SearchFiles {
   /** Simple command-line based search demo. */
   public static void main(String[] args) throws Exception {
     String usage =
-      "Usage:\tjava org.apache.lucene.demo.SearchFiles [-index dir] [-field f] [-repeat n] [-queries file] [-query string] [-raw] [-paging hitsPerPage]\n\nSee http://lucene.apache.org/java/4_0/demo.html for details.";
+      "Usage:\tjava org.apache.lucene.demo.SearchFiles [-index dir] [-field f] [-repeat n] [-queries file] [-query string] [-raw] [-paging hitsPerPage]\n\nSee http://lucene.apache.org/core/4_1_0/demo/ for details.";
     if (args.length > 0 && ("-h".equals(args[0]) || "-help".equals(args[0]))) {
       System.out.println(usage);
       System.exit(0);

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/build.xml?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/build.xml (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/build.xml Fri Jan 18 18:30:54 2013
@@ -30,19 +30,13 @@
 
   <property name="examples.dir" location="src/examples"/>
 
-  <path id="classpath">
-    <path refid="base.classpath" />
-    <pathelement location="${build.dir}/classes/java" />
-    <pathelement location="${build.dir}/classes/examples" />
-  </path>
-    
   <path id="examples.classpath">
     <path refid="classpath" />
     <pathelement location="${build.dir}/classes/java" />
     <pathelement path="${analyzers-common.jar}" />
   </path>
 
-  <path id="test.classpath">
+	<path id="test.classpath">
     <path refid="test.base.classpath" />
     <pathelement location="${build.dir}/classes/examples" />
     <!-- TODO, cut over tests to MockAnalyzer etc and nuke this dependency -->
@@ -81,5 +75,12 @@
       </links>
     </invoke-module-javadoc>
   </target>
-    
+
+  <target name="run-encoding-benchmark" depends="compile-test">
+    <java classname="org.apache.lucene.util.encoding.EncodingSpeed" fork="true" failonerror="true">
+      <classpath refid="test.classpath" />
+    	<classpath path="${build.dir}/classes/test" />
+    </java>
+  </target>
+	
 </project>

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java Fri Jan 18 18:30:54 2013
@@ -2,16 +2,6 @@ package org.apache.lucene.facet.example.
 
 import java.util.List;
 
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopScoreDocCollector;
-import org.apache.lucene.store.Directory;
-
-import org.apache.lucene.search.MultiCollector;
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.example.simple.SimpleUtils;
 import org.apache.lucene.facet.search.AdaptiveFacetsAccumulator;
@@ -22,6 +12,15 @@ 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.directory.DirectoryTaxonomyReader;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.store.Directory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -78,8 +77,8 @@ public class AdaptiveSearcher {
     ScoredDocIdCollector docIdsCollecor = ScoredDocIdCollector.create(indexReader.maxDoc(), false);
     
     // Faceted search parameters indicate which facets are we interested in 
-    FacetSearchParams facetSearchParams = new FacetSearchParams();
-    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
+    FacetSearchParams facetSearchParams = new FacetSearchParams(
+        new CountFacetRequest(new CategoryPath("root", "a"), 10));
     
     // search, into both collectors. note: in case only facets accumulation 
     // is required, the topDocCollector part can be totally discarded

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java Fri Jan 18 18:30:54 2013
@@ -3,22 +3,20 @@ package org.apache.lucene.facet.example.
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.lucene.index.AtomicReader;
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.MultiReader;
-import org.apache.lucene.store.Directory;
-
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.index.OrdinalMappingAtomicReader;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 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;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.store.Directory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -88,12 +86,13 @@ public class TaxonomyMergeUtils {
     destTaxWriter.addTaxonomy(srcTaxDir, map);
 
     int ordinalMap[] = map.getMap();
-    FacetIndexingParams params = new DefaultFacetIndexingParams();
+    FacetIndexingParams params = FacetIndexingParams.ALL_PARENTS;
 
     DirectoryReader reader = DirectoryReader.open(srcIndexDir, -1);
     List<AtomicReaderContext> leaves = reader.leaves();
-    AtomicReader wrappedLeaves[] = new AtomicReader[leaves.size()];
-    for (int i = 0; i < leaves.size(); i++) {
+    int numReaders = leaves.size();
+    AtomicReader wrappedLeaves[] = new AtomicReader[numReaders];
+    for (int i = 0; i < numReaders; i++) {
       wrappedLeaves[i] = new OrdinalMappingAtomicReader(leaves.get(i).reader(), ordinalMap, params);
     }
     try {

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java Fri Jan 18 18:30:54 2013
@@ -1,27 +1,27 @@
 package org.apache.lucene.facet.example.multiCL;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
-
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.example.simple.SimpleUtils;
-import org.apache.lucene.facet.index.CategoryDocumentBuilder;
+import org.apache.lucene.facet.index.FacetFields;
 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.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -74,22 +74,18 @@ public class MultiCLIndexer {
       + "reprehenderit qui in ea voluptate velit esse quam nihil molestiae "
       + "consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur";
   // PerDimensionIndexingParams for multiple category lists
-  public static PerDimensionIndexingParams MULTI_IPARAMS = new PerDimensionIndexingParams();
+  public static final PerDimensionIndexingParams MULTI_IPARAMS;
 
   // Initialize PerDimensionIndexingParams
   static {
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("0"),
-        new CategoryListParams(new Term("$Digits", "Zero")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("1"),
-        new CategoryListParams(new Term("$Digits", "One")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("2"),
-        new CategoryListParams(new Term("$Digits", "Two")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("3"),
-        new CategoryListParams(new Term("$Digits", "Three")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("4"),
-        new CategoryListParams(new Term("$Digits", "Four")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("5"),
-        new CategoryListParams(new Term("$Digits", "Five")));
+    Map<CategoryPath, CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+    paramsMap.put(new CategoryPath("0"), new CategoryListParams("$Digits$Zero"));
+    paramsMap.put(new CategoryPath("1"), new CategoryListParams("$Digits$One"));
+    paramsMap.put(new CategoryPath("2"), new CategoryListParams("$Digits$Two"));
+    paramsMap.put(new CategoryPath("3"), new CategoryListParams("$Digits$Three"));
+    paramsMap.put(new CategoryPath("4"), new CategoryListParams("$Digits$Four"));
+    paramsMap.put(new CategoryPath("5"), new CategoryListParams("$Digits$Five"));
+    MULTI_IPARAMS = new PerDimensionIndexingParams(paramsMap);
   }
   
   /**
@@ -164,10 +160,8 @@ public class MultiCLIndexer {
       List<CategoryPath> facetList = Arrays.asList(cPaths[docNum]);
 
       // we do not alter indexing parameters!
-      // a category document builder will add the categories to a document
-      // once build() is called
-      CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(
-          taxo, iParams).setCategoryPaths(facetList);
+      // FacetFields adds the categories to the document in addFields()
+      FacetFields facetFields = new FacetFields(taxo, iParams);
 
       // create a plain Lucene document and add some regular Lucene fields
       // to it
@@ -176,7 +170,7 @@ public class MultiCLIndexer {
       doc.add(new TextField(SimpleUtils.TEXT, docTexts[docNum], Field.Store.NO));
 
       // finally add the document to the index
-      categoryDocBuilder.build(doc);
+      facetFields.addFields(doc, facetList);
       iw.addDocument(doc);
       
       nDocsAdded++;

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java Fri Jan 18 18:30:54 2013
@@ -1,5 +1,6 @@
 package org.apache.lucene.facet.example.multiCL;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.lucene.index.DirectoryReader;
@@ -17,6 +18,7 @@ import org.apache.lucene.facet.example.s
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.FacetsCollector;
 import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
 import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -91,17 +93,14 @@ public class MultiCLSearcher {
     Query q = new TermQuery(new Term(SimpleUtils.TEXT, "Quis"));
     ExampleUtils.log("Query: " + q);
 
-    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10,
-        true);
+    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
 
     // Faceted search parameters indicate which facets are we interested in
-    FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("5"), 10));
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("5", "5"), 10));
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("6", "2"), 10));
+    List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+    facetRequests.add(new CountFacetRequest(new CategoryPath("5"), 10));
+    facetRequests.add(new CountFacetRequest(new CategoryPath("5", "5"), 10));
+    facetRequests.add(new CountFacetRequest(new CategoryPath("6", "2"), 10));
+    FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
 
     // Facets collector is the simplest interface for faceted search.
     // It provides faceted search functions that are sufficient to many

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java Fri Jan 18 18:30:54 2013
@@ -6,16 +6,15 @@ import java.util.List;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.store.Directory;
-
 import org.apache.lucene.facet.example.ExampleUtils;
-import org.apache.lucene.facet.index.CategoryDocumentBuilder;
+import org.apache.lucene.facet.index.FacetFields;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.store.Directory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -50,31 +49,29 @@ public class SimpleIndexer {
   public static void index (Directory indexDir, Directory taxoDir) throws Exception {
 
     // create and open an index writer
-    IndexWriter iw = new IndexWriter(indexDir, new IndexWriterConfig(ExampleUtils.EXAMPLE_VER, SimpleUtils.analyzer));
+    final IndexWriter iw = new IndexWriter(indexDir, 
+        new IndexWriterConfig(ExampleUtils.EXAMPLE_VER, SimpleUtils.analyzer));
 
     // create and open a taxonomy writer
-    TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
+    final TaxonomyWriter taxo = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE);
 
+    // FacetFields adds the categories to the document in addFields()
+    final FacetFields facetFields = new FacetFields(taxo);
+    
     // loop over  sample documents 
     int nDocsAdded = 0;
     int nFacetsAdded = 0;
-    for (int docNum=0; docNum<SimpleUtils.docTexts.length; docNum++) {
-
+    for (int docNum = 0; docNum < SimpleUtils.docTexts.length; docNum++) {
       // obtain the sample facets for current document
       List<CategoryPath> facetList = Arrays.asList(SimpleUtils.categories[docNum]);
 
-      // we do not alter indexing parameters!  
-      // a category document builder will add the categories to a document once build() is called
-      CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
-
       // create a plain Lucene document and add some regular Lucene fields to it 
       Document doc = new Document();
       doc.add(new TextField(SimpleUtils.TITLE, SimpleUtils.docTitles[docNum], Field.Store.YES));
       doc.add(new TextField(SimpleUtils.TEXT, SimpleUtils.docTexts[docNum], Field.Store.NO));
 
-      // invoke the category document builder for adding categories to the document and,
-      // as required, to the taxonomy index 
-      categoryDocBuilder.build(doc);
+      // add the facet fields to the document
+      facetFields.addFields(doc, facetList);
 
       // finally add the document to the index
       iw.addDocument(doc);

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java Fri Jan 18 18:30:54 2013
@@ -1,18 +1,10 @@
 package org.apache.lucene.facet.example.simple;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopScoreDocCollector;
-
-import org.apache.lucene.search.MultiCollector;
 import org.apache.lucene.facet.example.ExampleUtils;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.DrillDown;
 import org.apache.lucene.facet.search.FacetsCollector;
@@ -23,6 +15,13 @@ import org.apache.lucene.facet.search.re
 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.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopScoreDocCollector;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -101,16 +100,11 @@ public class SimpleSearcher {
     TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
 
     if (indexingParams == null) {
-      indexingParams = new DefaultFacetIndexingParams();
+      indexingParams = FacetIndexingParams.ALL_PARENTS;
     }
     
     // Faceted search parameters indicate which facets are we interested in
-    FacetSearchParams facetSearchParams = new FacetSearchParams(indexingParams);
-    
-    // Add the facet requests of interest to the search params
-    for (FacetRequest frq : facetRequests) {
-      facetSearchParams.addFacetRequest(frq);
-    }
+    FacetSearchParams facetSearchParams = new FacetSearchParams(Arrays.asList(facetRequests), indexingParams);
 
     FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
 
@@ -138,6 +132,8 @@ public class SimpleSearcher {
   public static List<FacetResult> searchWithDrillDown(IndexReader indexReader,
       TaxonomyReader taxoReader) throws Exception {
 
+    final FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
+    
     // base query the user is interested in
     Query baseQuery = new TermQuery(new Term(SimpleUtils.TEXT, "white"));
 
@@ -145,7 +141,7 @@ public class SimpleSearcher {
     CountFacetRequest facetRequest = new CountFacetRequest(new CategoryPath("root","a"), 10);
     
     // initial search - all docs matching the base query will contribute to the accumulation 
-    List<FacetResult> res1 = searchWithRequest(indexReader, taxoReader, null, facetRequest);
+    List<FacetResult> res1 = searchWithRequest(indexReader, taxoReader, indexingParams, facetRequest);
     
     // a single result (because there was a single request) 
     FacetResult fres = res1.get(0);
@@ -157,12 +153,12 @@ public class SimpleSearcher {
     CategoryPath categoryOfInterest = resIterator.next().getLabel();
     
     // drill-down preparation: turn the base query into a drill-down query for the category of interest
-    Query q2 = DrillDown.query(baseQuery, categoryOfInterest);
+    Query q2 = DrillDown.query(indexingParams, baseQuery, categoryOfInterest);
     
     // that's it - search with the new query and we're done!
     // only documents both matching the base query AND containing the 
     // category of interest will contribute to the new accumulation
-    return searchWithRequestAndQuery(q2, indexReader, taxoReader, null, facetRequest);
+    return searchWithRequestAndQuery(q2, indexReader, taxoReader, indexingParams, facetRequest);
   }
   
 }

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleUtils.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleUtils.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleUtils.java Fri Jan 18 18:30:54 2013
@@ -1,11 +1,7 @@
 package org.apache.lucene.facet.example.simple;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 

Modified: lucene/dev/branches/LUCENE-2878/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html Fri Jan 18 18:30:54 2013
@@ -538,7 +538,7 @@ parameters it defines, the following two
 forms: category-tokens (for drill-down) and category-list-tokens (for
 accumulation). This parameter allows to specify, for each category, the
 Lucene term used for maintaining the category-list-tokens for that category.
-The default implementation in <code>DefaultFacetIndexingParams</code> maintains
+The default implementation in <code>FacetIndexingParams</code> maintains
 this information for all categories under the same special dedicated term.
 One case where it is needed to maintain two categories in separate category
 lists, is when it is known that at search time it would be required to use
@@ -548,7 +548,7 @@ call.</li>
 for example, the partition size is set to 1000, a distinct sub-term is used for
 maintaining each 1000 categories, e.g. term1 for categories 0 to 999, term2
 for categories 1000 to 1999, etc. The default implementation in
-<code>DefaultFacetIndexingParams</code> maintains category lists in a single
+<code>FacetIndexingParams</code> maintains category lists in a single
 partition, hence it defines the partition size as <code>Integer.MAX_VALUE</code>. The
 importance of this parameter is on allowing to handle very large
 taxonomies without exhausting RAM resources. This is because at facet