lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1436566 [2/3] - in /lucene/dev/branches/lucene4547: ./ lucene/ lucene/benchmark/ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ lucene/core/ lucene/co...
Date Mon, 21 Jan 2013 19:23:26 GMT
Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java Mon Jan 21 19:23:25 2013
@@ -11,7 +11,6 @@ import org.apache.lucene.facet.search.pa
 import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.search.results.FacetResultNode;
-import org.apache.lucene.facet.search.results.MutableFacetResultNode;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.index.IndexReader;
 
@@ -41,7 +40,7 @@ import org.apache.lucene.index.IndexRead
  * Note: Sampling accumulation (Accumulation over a sampled-set of the results),
  * does not guarantee accurate values for
  * {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResultNode#residue}.
  * 
  * @lucene.experimental
  */
@@ -169,12 +168,39 @@ public abstract class Sampler {
     
     FacetRequest origFrq = sampledFreq.orig;
 
-    MutableFacetResultNode trimmedRootNode = MutableFacetResultNode.toImpl(facetResult.getFacetResultNode());
-    trimmedRootNode.trimSubResults(origFrq.getNumResults());
+    FacetResultNode trimmedRootNode = facetResult.getFacetResultNode();
+    trimSubResults(trimmedRootNode, origFrq.getNumResults());
     
     return new FacetResult(origFrq, trimmedRootNode, facetResult.getNumValidDescendants());
   }
   
+  /** Trim sub results to a given size. */
+  private void trimSubResults(FacetResultNode node, int size) {
+    if (node.subResults == FacetResultNode.EMPTY_SUB_RESULTS || node.subResults.size() == 0) {
+      return;
+    }
+
+    ArrayList<FacetResultNode> trimmed = new ArrayList<FacetResultNode>(size);
+    for (int i = 0; i < node.subResults.size() && i < size; i++) {
+      FacetResultNode trimmedNode = node.subResults.get(i);
+      trimSubResults(trimmedNode, size);
+      trimmed.add(trimmedNode);
+    }
+    
+    /*
+     * If we are trimming, it means Sampling is in effect and the extra
+     * (over-sampled) results are being trimmed. Although the residue is not
+     * guaranteed to be accurate for Sampling, we try our best to fix it.
+     * The node's residue now will take under account the sub-nodes we're
+     * trimming.
+     */
+    for (int i = size; i < node.subResults.size(); i++) {
+      node.residue += node.subResults.get(i).value;
+    }
+    
+    node.subResults = trimmed;
+  }
+
   /**
    * Over-sampled search params, wrapping each request with an over-sampled one.
    */
@@ -184,11 +210,11 @@ public abstract class Sampler {
     double overSampleFactor = getSamplingParams().getOversampleFactor();
     if (overSampleFactor > 1) { // any factoring to do?
       List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
-      for (FacetRequest frq : original.getFacetRequests()) {
+      for (FacetRequest frq : original.facetRequests) {
         int overSampledNumResults = (int) Math.ceil(frq.getNumResults() * overSampleFactor);
         facetRequests.add(new OverSampledFacetRequest(frq, overSampledNumResults));
       }
-      res = new FacetSearchParams(facetRequests, original.getFacetIndexingParams());
+      res = new FacetSearchParams(facetRequests, original.indexingParams);
     }
     return res;
   }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java Mon Jan 21 19:23:25 2013
@@ -49,7 +49,7 @@ import org.apache.lucene.index.IndexRead
  * Note: Sampling accumulation (Accumulation over a sampled-set of the results),
  * does not guarantee accurate values for
  * {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResultNode#residue}.
  * 
  * @see Sampler
  * @lucene.experimental

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java Mon Jan 21 19:23:25 2013
@@ -74,10 +74,9 @@ class TakmiSampleFixer implements Sample
    *          docids in effect
    * @throws IOException If there is a low-level I/O error.
    */
-  private void fixResultNode(FacetResultNode facetResNode, ScoredDocIDs docIds)
-      throws IOException {
+  private void fixResultNode(FacetResultNode facetResNode, ScoredDocIDs docIds) throws IOException {
     recount(facetResNode, docIds);
-    for (FacetResultNode frn : facetResNode.getSubResults()) {
+    for (FacetResultNode frn : facetResNode.subResults) {
       fixResultNode(frn, docIds);
     }
   }
@@ -101,7 +100,10 @@ class TakmiSampleFixer implements Sample
      * facet results was exercise, we need to calculate them anyway, so
      * in essence sampling with recounting spends some extra cycles for
      * labeling results for which labels are not required. */
-    CategoryPath catPath = fresNode.getLabel(taxonomyReader); // force labeling
+    if (fresNode.label == null) {
+      fresNode.label = taxonomyReader.getPath(fresNode.ordinal);
+    }
+    CategoryPath catPath = fresNode.label;
 
     Term drillDownTerm = DrillDown.term(searchParams, catPath);
     // TODO (Facet): avoid Multi*?
@@ -109,8 +111,7 @@ class TakmiSampleFixer implements Sample
     int updatedCount = countIntersection(MultiFields.getTermDocsEnum(indexReader, liveDocs,
                                                                      drillDownTerm.field(), drillDownTerm.bytes(),
                                                                      0), docIds.iterator());
-
-    fresNode.setValue(updatedCount);
+    fresNode.value = updatedCount;
   }
 
   /**

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java Mon Jan 21 19:23:25 2013
@@ -48,12 +48,19 @@ public class CategoryPath implements Com
 
   // Used by subpath
   private CategoryPath(CategoryPath copyFrom, int prefixLen) {
+    // while the code which calls this method is safe, at some point a test
+    // tripped on AIOOBE in toString, but we failed to reproduce. adding the
+    // assert as a safety check.
+    assert prefixLen > 0 && prefixLen <= copyFrom.components.length : 
+      "prefixLen cannot be negative nor larger than the given components' length: prefixLen=" + prefixLen
+        + " components.length=" + copyFrom.components.length;
     this.components = copyFrom.components;
     length = prefixLen;
   }
   
   /** Construct from the given path components. */
   public CategoryPath(String... components) {
+    assert components.length > 0 : "use CategoryPath.EMPTY to create an empty path";
     this.components = components;
     length = components.length;
   }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java Mon Jan 21 19:23:25 2013
@@ -14,7 +14,6 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
 import org.apache.lucene.document.Document;
@@ -30,7 +29,7 @@ import org.apache.lucene.facet.taxonomy.
 import org.apache.lucene.facet.taxonomy.writercache.lru.LruTaxonomyWriterCache;
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.CorruptIndexException; // javadocs
+import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.IndexReader;
@@ -45,7 +44,7 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.index.TieredMergePolicy;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.LockObtainFailedException; // javadocs
+import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.NativeFSLockFactory;
 import org.apache.lucene.store.SimpleFSLockFactory;
 import org.apache.lucene.util.BytesRef;
@@ -303,8 +302,7 @@ public class DirectoryTaxonomyWriter imp
  
     // Make sure we use a MergePolicy which always merges adjacent segments and thus
     // keeps the doc IDs ordered as well (this is crucial for the taxonomy index).
-    return new IndexWriterConfig(Version.LUCENE_50,
-        new KeywordAnalyzer()).setOpenMode(openMode).setMergePolicy(
+    return new IndexWriterConfig(Version.LUCENE_50, null).setOpenMode(openMode).setMergePolicy(
         new LogByteSizeMergePolicy());
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java Mon Jan 21 19:23:25 2013
@@ -73,12 +73,12 @@ public class ResultSortUtils {
 
     @Override
     protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
-      double value0 = arg0.getValue();
-      double value1 = arg1.getValue();
+      double value0 = arg0.value;
+      double value1 = arg1.value;
 
       int valueCompare = Double.compare(value0, value1);
       if (valueCompare == 0) { 
-        return arg0.getOrdinal() < arg1.getOrdinal();
+        return arg0.ordinal < arg1.ordinal;
       }
 
       return valueCompare < 0;
@@ -93,40 +93,38 @@ public class ResultSortUtils {
 
     @Override
     protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
-      double value0 = arg0.getValue();
-      double value1 = arg1.getValue();
+      double value0 = arg0.value;
+      double value1 = arg1.value;
 
       int valueCompare = Double.compare(value0, value1);
       if (valueCompare == 0) { 
-        return arg0.getOrdinal() > arg1.getOrdinal();
+        return arg0.ordinal > arg1.ordinal;
       }
 
       return valueCompare > 0;
     }
   }
 
-  private static class MinOrdinalHeap extends
-  PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
+  private static class MinOrdinalHeap extends PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
     public MinOrdinalHeap(int size) {
       super(size);
     }
 
     @Override
     protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
-      return arg0.getOrdinal() < arg1.getOrdinal();
+      return arg0.ordinal < arg1.ordinal;
     }
 
   }
 
-  private static class MaxOrdinalHeap extends
-  PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
+  private static class MaxOrdinalHeap extends PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
     public MaxOrdinalHeap(int size) {
       super(size);
     }
 
     @Override
     protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
-      return arg0.getOrdinal() > arg1.getOrdinal();
+      return arg0.ordinal > arg1.ordinal;
     }
 
   }
@@ -156,10 +154,9 @@ public class ResultSortUtils {
         Collections.sort(resultNodes, new Comparator<FacetResultNode>() {
           @Override
           public int compare(FacetResultNode o1, FacetResultNode o2) {
-            int value = Double.compare(o1.getValue(), o2
-                .getValue());
+            int value = Double.compare(o1.value, o2.value);
             if (value == 0) {
-              value = o1.getOrdinal() - o2.getOrdinal();
+              value = o1.ordinal - o2.ordinal;
             }
             if (accending) {
               value = -value;
@@ -198,4 +195,5 @@ public class ResultSortUtils {
       resultNodes.clear();
     }
   }
+  
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java Mon Jan 21 19:23:25 2013
@@ -196,7 +196,7 @@ public abstract class FacetTestBase exte
    * test with different faceted search params.
    */
   protected FacetSearchParams getFacetSearchParams(FacetIndexingParams iParams, FacetRequest... facetRequests) {
-    return new FacetSearchParams(Arrays.asList(facetRequests), iParams);
+    return new FacetSearchParams(iParams, facetRequests);
   }
 
   /**
@@ -246,7 +246,7 @@ public abstract class FacetTestBase exte
   /** convenience method: convert sub results to an array */  
   protected static FacetResultNode[] resultNodesAsArray(FacetResultNode parentRes) {
     ArrayList<FacetResultNode> a = new ArrayList<FacetResultNode>();
-    for (FacetResultNode frn : parentRes.getSubResults()) {
+    for (FacetResultNode frn : parentRes.subResults) {
       a.add(frn);
     }
     return a.toArray(new FacetResultNode[0]);
@@ -305,42 +305,27 @@ public abstract class FacetTestBase exte
     
   /** Validate counts for returned facets, and that there are not too many results */
   private static void assertCountsAndCardinality(Map<CategoryPath,Integer> facetCountsTruth,  FacetResultNode resNode, int reqNumResults) throws Exception {
-    int actualNumResults = resNode.getNumSubResults();
+    int actualNumResults = resNode.subResults.size();
     if (VERBOSE) {
       System.out.println("NumResults: " + actualNumResults);
     }
     assertTrue("Too many results!", actualNumResults <= reqNumResults);
-    for (FacetResultNode subRes : resNode.getSubResults()) {
-      assertEquals("wrong count for: "+subRes, facetCountsTruth.get(subRes.getLabel()).intValue(), (int)subRes.getValue());
+    for (FacetResultNode subRes : resNode.subResults) {
+      assertEquals("wrong count for: "+subRes, facetCountsTruth.get(subRes.label).intValue(), (int)subRes.value);
       assertCountsAndCardinality(facetCountsTruth, subRes, reqNumResults); // recurse into child results
     }
   }
-  
+
   /** Validate results equality */
   protected static void assertSameResults(List<FacetResult> expected, List<FacetResult> actual) {
-    String expectedResults = resStringValueOnly(expected);
-    String actualResults = resStringValueOnly(actual);
-    if (!expectedResults.equals(actualResults)) {
-      System.err.println("Results are not the same!");
-      System.err.println("Expected:\n" + expectedResults);
-      System.err.println("Actual:\n" + actualResults);
-      throw new NotSameResultError();
-    }
-  }
-  
-  /** exclude the residue and numDecendants because it is incorrect in sampling */
-  private static final String resStringValueOnly(List<FacetResult> results) {
-    StringBuilder sb = new StringBuilder();
-    for (FacetResult facetRes : results) {
-      sb.append(facetRes.toString()).append('\n');
-    }
-    return sb.toString().replaceAll("Residue:.*.0", "").replaceAll("Num valid Descendants.*", "");
-  }
-  
-  /** Special Error class for ability to ignore only this error and retry... */ 
-  public static class NotSameResultError extends Error {
-    public NotSameResultError() {
-      super("Results are not the same!");
+    assertEquals("wrong number of facet results", expected.size(), actual.size());
+    int size = expected.size();
+    for (int i = 0; i < size; i++) {
+      FacetResult expectedResult = expected.get(i);
+      FacetResult actualResult = actual.get(i);
+      String expectedStr = FacetTestUtils.toSimpleString(expectedResult);
+      String actualStr = FacetTestUtils.toSimpleString(actualResult);
+      assertEquals("Results not the same!\nExpected:" + expectedStr + "\nActual:\n" + actualStr, expectedStr, actualStr);
     }
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java Mon Jan 21 19:23:25 2013
@@ -4,12 +4,14 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.analysis.MockAnalyzer;
 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.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
@@ -45,6 +47,33 @@ import org.apache.lucene.util.LuceneTest
 
 public class FacetTestUtils {
 
+  public static class IndexTaxonomyReaderPair {
+    public DirectoryReader indexReader;
+    public DirectoryTaxonomyReader taxReader;
+    public IndexSearcher indexSearcher;
+
+    public void close() throws IOException {
+      indexReader.close();
+      taxReader.close();
+    }
+
+  }
+
+  public static class IndexTaxonomyWriterPair {
+    public IndexWriter indexWriter;
+    public TaxonomyWriter taxWriter;
+
+    public void close() throws IOException {
+      indexWriter.close();
+      taxWriter.close();
+    }
+
+    public void commit() throws IOException {
+      indexWriter.commit();
+      taxWriter.commit();
+    }
+  }
+
   public static Directory[][] createIndexTaxonomyDirs(int number) {
     Directory[][] dirs = new Directory[number][2];
     for (int i = 0; i < number; i++) {
@@ -54,8 +83,7 @@ public class FacetTestUtils {
     return dirs;
   }
 
-  public static IndexTaxonomyReaderPair[] createIndexTaxonomyReaderPair(
-      Directory[][] dirs) throws IOException {
+  public static IndexTaxonomyReaderPair[] createIndexTaxonomyReaderPair(Directory[][] dirs) throws IOException {
     IndexTaxonomyReaderPair[] pairs = new IndexTaxonomyReaderPair[dirs.length];
     for (int i = 0; i < dirs.length; i++) {
       IndexTaxonomyReaderPair pair = new IndexTaxonomyReaderPair();
@@ -66,15 +94,13 @@ public class FacetTestUtils {
     }
     return pairs;
   }
-
-  public static IndexTaxonomyWriterPair[] createIndexTaxonomyWriterPair(
-      Directory[][] dirs) throws IOException {
+  
+  public static IndexTaxonomyWriterPair[] createIndexTaxonomyWriterPair(Directory[][] dirs) throws IOException {
     IndexTaxonomyWriterPair[] pairs = new IndexTaxonomyWriterPair[dirs.length];
     for (int i = 0; i < dirs.length; i++) {
       IndexTaxonomyWriterPair pair = new IndexTaxonomyWriterPair();
       pair.indexWriter = new IndexWriter(dirs[i][0], new IndexWriterConfig(
-          LuceneTestCase.TEST_VERSION_CURRENT, new StandardAnalyzer(
-              LuceneTestCase.TEST_VERSION_CURRENT)));
+          LuceneTestCase.TEST_VERSION_CURRENT, new MockAnalyzer(LuceneTestCase.random())));
       pair.taxWriter = new DirectoryTaxonomyWriter(dirs[i][1]);
       pair.indexWriter.commit();
       pair.taxWriter.commit();
@@ -83,9 +109,8 @@ public class FacetTestUtils {
     return pairs;
   }
 
-  public static Collector[] search(IndexSearcher searcher,
-      TaxonomyReader taxonomyReader, FacetIndexingParams iParams, int k,
-      String... facetNames) throws IOException {
+  public static Collector[] search(IndexSearcher searcher, TaxonomyReader taxonomyReader, FacetIndexingParams iParams, 
+      int k, String... facetNames) throws IOException {
     
     Collector[] collectors = new Collector[2];
     
@@ -97,10 +122,8 @@ public class FacetTestUtils {
     }
     FacetSearchParams facetSearchParams = new FacetSearchParams(fRequests, iParams);
 
-    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(
-        searcher.getIndexReader().maxDoc(), true);
-    FacetsCollector facetsCollector = new FacetsCollector(
-        facetSearchParams, searcher.getIndexReader(), taxonomyReader);
+    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(searcher.getIndexReader().maxDoc(), true);
+    FacetsCollector facetsCollector = FacetsCollector.create(facetSearchParams, searcher.getIndexReader(), taxonomyReader);
     Collector mColl = MultiCollector.wrap(topDocsCollector, facetsCollector);
     
     collectors[0] = topDocsCollector;
@@ -109,31 +132,17 @@ public class FacetTestUtils {
     searcher.search(new MatchAllDocsQuery(), mColl);
     return collectors;
   }
-  
-  public static class IndexTaxonomyReaderPair {
-    public DirectoryReader indexReader;
-    public DirectoryTaxonomyReader taxReader;
-    public IndexSearcher indexSearcher;
-
-    public void close() throws IOException {
-      indexReader.close();
-      taxReader.close();
-    }
 
+  public static String toSimpleString(FacetResult fr) {
+    StringBuilder sb = new StringBuilder();
+    toSimpleString(0, sb, fr.getFacetResultNode(), "");
+    return sb.toString();
   }
-
-  public static class IndexTaxonomyWriterPair {
-    public IndexWriter indexWriter;
-    public TaxonomyWriter taxWriter;
-
-    public void close() throws IOException {
-      indexWriter.close();
-      taxWriter.close();
-    }
-
-    public void commit() throws IOException {
-      indexWriter.commit();
-      taxWriter.commit();
+  
+  private static void toSimpleString(int depth, StringBuilder sb, FacetResultNode node, String indent) {
+    sb.append(indent + node.label.components[depth] + " (" + (int) node.value + ")\n");
+    for (FacetResultNode childNode : node.subResults) {
+      toSimpleString(depth + 1, sb, childNode, indent + "  ");
     }
   }
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java Mon Jan 21 19:23:25 2013
@@ -45,10 +45,10 @@ public class TestAssociationExample exte
     assertEquals("Wrong number of results!", 1, res.getFacetResults().size());
     assertEquals("Wrong number of facets!", 2, res.getFacetResults().get(0).getNumValidDescendants());
     
-    Iterable<? extends FacetResultNode> it = res.getFacetResults().get(0).getFacetResultNode().getSubResults();
+    Iterable<? extends FacetResultNode> it = res.getFacetResults().get(0).getFacetResultNode().subResults;
     int i = 0;
     for (FacetResultNode fResNode : it) {
-      assertEquals("Wrong result for facet "+fResNode.getLabel(), expectedResults[i++], fResNode.getValue(), 1E-5);
+      assertEquals("Wrong result for facet "+fResNode.label, expectedResults[i++], fResNode.value, 1E-5);
     }
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java Mon Jan 21 19:23:25 2013
@@ -43,45 +43,35 @@ public class TestMultiCLExample extends 
     List<FacetResult> results = exampleResults.getFacetResults();
     FacetResult result = results.get(0);
     assertNotNull("Result should not be null", result);
-    assertEquals("Invalid label", "5", result.getFacetResultNode()
-        .getLabel().toString());
-    assertEquals("Invalid value", 2.0, result.getFacetResultNode()
-        .getValue(), 0.0);
-    assertEquals("Invalid # of subresults", 3, result.getFacetResultNode()
-        .getNumSubResults());
+    FacetResultNode node = result.getFacetResultNode();
+    assertEquals("Invalid label", "5", node.label.toString());
+    assertEquals("Invalid value", 2.0, node.value, 0.0);
+    assertEquals("Invalid # of subresults", 3, node.subResults.size());
 
-    Iterator<? extends FacetResultNode> subResults = result
-        .getFacetResultNode().getSubResults().iterator();
+    Iterator<? extends FacetResultNode> subResults = node.subResults.iterator();
     FacetResultNode sub = subResults.next();
-    assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
-    assertEquals("Invalid subresult label", "5/2", sub.getLabel()
-        .toString());
+    assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+    assertEquals("Invalid subresult label", "5/2", sub.label.toString());
     sub = subResults.next();
-    assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
-    assertEquals("Invalid subresult label", "5/7", sub.getLabel()
-        .toString());
+    assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+    assertEquals("Invalid subresult label", "5/7", sub.label.toString());
     sub = subResults.next();
-    assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
-    assertEquals("Invalid subresult label", "5/5", sub.getLabel()
-        .toString());
+    assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+    assertEquals("Invalid subresult label", "5/5", sub.label.toString());
 
     result = results.get(1);
+    node = result.getFacetResultNode();
     assertNotNull("Result should not be null", result);
-    assertEquals("Invalid label", "5/5", result.getFacetResultNode()
-        .getLabel().toString());
-    assertEquals("Invalid value", 1,
-        result.getFacetResultNode().getValue(), 0.0);
-    assertEquals("Invalid number of subresults", 0, result
-        .getFacetResultNode().getNumSubResults());
+    assertEquals("Invalid label", "5/5", node.label.toString());
+    assertEquals("Invalid value", 1, node.value, 0.0);
+    assertEquals("Invalid number of subresults", 0, node.subResults.size());
 
     result = results.get(2);
+    node = result.getFacetResultNode();
     assertNotNull("Result should not be null", result);
-    assertEquals("Invalid label", "6/2", result.getFacetResultNode()
-        .getLabel().toString());
-    assertEquals("Invalid value", 1,
-        result.getFacetResultNode().getValue(), 0.0);
-    assertEquals("Invalid number of subresults", 0, result
-        .getFacetResultNode().getNumSubResults());
+    assertEquals("Invalid label", "6/2", node.label.toString());
+    assertEquals("Invalid value", 1, node.value, 0.0);
+    assertEquals("Invalid number of subresults", 0, node.subResults.size());
 
   }
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java Mon Jan 21 19:23:25 2013
@@ -57,11 +57,11 @@ public class TestSimpleExample extends L
     FacetResult facetResult = res.getFacetResults().get(0);
     assertEquals("Wrong number of facets!",2, facetResult.getNumValidDescendants());
     
-    Iterator<? extends FacetResultNode> resIterator = facetResult.getFacetResultNode().getSubResults().iterator();
+    Iterator<? extends FacetResultNode> resIterator = facetResult.getFacetResultNode().subResults.iterator();
     assertTrue("Too few results", resIterator.hasNext());
-    assertEquals("wrong count for first result out of 2", 1, (int)resIterator.next().getValue());
+    assertEquals("wrong count for first result out of 2", 1, (int)resIterator.next().value);
     assertTrue("Too few results", resIterator.hasNext());
-    assertEquals("wrong count for second result out of 2", 1, (int)resIterator.next().getValue());
+    assertEquals("wrong count for second result out of 2", 1, (int)resIterator.next().value);
     assertFalse("Too many results!", resIterator.hasNext());
   }
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java Mon Jan 21 19:23:25 2013
@@ -71,13 +71,13 @@ public class OrdinalMappingReaderTest ex
     DirectoryTaxonomyReader taxReader = new DirectoryTaxonomyReader(taxDir);
     IndexSearcher searcher = newSearcher(reader1);
     FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("tag"), NUM_DOCS));
-    FacetsCollector collector = new FacetsCollector(fsp, reader1, taxReader);
+    FacetsCollector collector = FacetsCollector.create(fsp, reader1, taxReader);
     searcher.search(new MatchAllDocsQuery(), collector);
     FacetResult result = collector.getFacetResults().get(0);
     FacetResultNode node = result.getFacetResultNode();
-    for (FacetResultNode facet: node.getSubResults()) {
-      int weight = (int)facet.getValue();
-      int label = Integer.parseInt(facet.getLabel().components[1]);
+    for (FacetResultNode facet: node.subResults) {
+      int weight = (int)facet.value;
+      int label = Integer.parseInt(facet.label.components[1]);
       //System.out.println(label + ": " + weight);
       if (VERBOSE) {
         System.out.println(label + ": " + weight);

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java Mon Jan 21 19:23:25 2013
@@ -266,15 +266,15 @@ public class TestFacetsPayloadMigrationR
       requests.add(new CountFacetRequest(new CategoryPath(dim), 5));
     }
     FacetSearchParams fsp = new FacetSearchParams(requests, fip);
-    FacetsCollector fc = new FacetsCollector(fsp, indexReader, taxoReader);
+    FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
     MatchAllDocsQuery base = new MatchAllDocsQuery();
     searcher.search(base, fc);
     List<FacetResult> facetResults = fc.getFacetResults();
     assertEquals(requests.size(), facetResults.size());
     for (FacetResult res : facetResults) {
       FacetResultNode node = res.getFacetResultNode();
-      String dim = node.getLabel().components[0];
-      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) node.getValue());
+      String dim = node.label.components[0];
+      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) node.value);
     }
   }
   
@@ -283,18 +283,16 @@ public class TestFacetsPayloadMigrationR
     // verify drill-down
     for (String dim : expectedCounts.keySet()) {
       CategoryPath drillDownCP = new CategoryPath(dim);
-      ArrayList<FacetRequest> request = new ArrayList<FacetRequest>(1);
-      request.add(new CountFacetRequest(drillDownCP, 10));
-      FacetSearchParams fsp = new FacetSearchParams(request, fip);
+      FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(drillDownCP, 10));
       Query drillDown = DrillDown.query(fsp, new MatchAllDocsQuery(), drillDownCP);
       TotalHitCountCollector total = new TotalHitCountCollector();
-      FacetsCollector fc = new FacetsCollector(fsp, indexReader, taxoReader);
+      FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
       searcher.search(drillDown, MultiCollector.wrap(fc, total));
       assertTrue("no results for drill-down query " + drillDown, total.getTotalHits() > 0);
       List<FacetResult> facetResults = fc.getFacetResults();
       assertEquals(1, facetResults.size());
       FacetResultNode rootNode = facetResults.get(0).getFacetResultNode();
-      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) rootNode.getValue());
+      assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) rootNode.value);
     }
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java Mon Jan 21 19:23:25 2013
@@ -46,7 +46,6 @@ public class FacetIndexingParamsTest ext
     assertEquals("3 characters should be written", 3, numchars);
     assertEquals("wrong drill-down term text", expectedDDText, new String(
         buf, 0, numchars));
-    CategoryListParams clParams = dfip.getCategoryListParams(null);
     assertEquals("partition for all ordinals is the first", "", 
         PartitionsUtils.partitionNameByOrdinal(dfip, 250));
     assertEquals("for partition 0, the same name should be returned",
@@ -75,7 +74,7 @@ public class FacetIndexingParamsTest ext
     PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
     assertEquals("path policy does not match default for root", pathPolicy.shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
     for (int i = 0; i < 30; i++) {
-      int nComponents = random().nextInt(10);
+      int nComponents = random().nextInt(10) + 1;
       String[] components = new String[nComponents];
       for (int j = 0; j < components.length; j++) {
         components[j] = (Integer.valueOf(random().nextInt(30))).toString();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/SamplingWrapperTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/SamplingWrapperTest.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/SamplingWrapperTest.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/SamplingWrapperTest.java Mon Jan 21 19:23:25 2013
@@ -29,11 +29,10 @@ import org.apache.lucene.facet.taxonomy.
 public class SamplingWrapperTest extends BaseSampleTestTopK {
 
   @Override
-  protected FacetsAccumulator getSamplingAccumulator(Sampler sampler,
-      TaxonomyReader taxoReader, IndexReader indexReader,
-      FacetSearchParams searchParams) {
-    FacetsAccumulator fExtrctr = new StandardFacetsAccumulator(searchParams,
-        indexReader, taxoReader);
-    return new SamplingWrapper(fExtrctr, sampler);
+  protected FacetsAccumulator getSamplingAccumulator(Sampler sampler, TaxonomyReader taxoReader, 
+      IndexReader indexReader, FacetSearchParams searchParams) {
+    FacetsAccumulator fa = new StandardFacetsAccumulator(searchParams, indexReader, taxoReader);
+    return new SamplingWrapper(fa, sampler);
   }
+  
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java Mon Jan 21 19:23:25 2013
@@ -17,20 +17,23 @@ package org.apache.lucene.facet.search;
  * limitations under the License.
  */
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.lucene.document.Document;
+import org.apache.lucene.facet.FacetTestUtils;
 import org.apache.lucene.facet.index.FacetFields;
 import org.apache.lucene.facet.search.params.CountFacetRequest;
 import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.search.results.FacetResult;
-import org.apache.lucene.facet.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.facet.util.PrintTaxonomyStats;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.search.IndexSearcher;
@@ -89,7 +92,7 @@ public class TestDemoFacets extends Luce
         new CountFacetRequest(new CategoryPath("Author"), 10));
 
     // Aggregatses the facet counts:
-    FacetsCollector c = new FacetsCollector(fsp, searcher.getIndexReader(), taxoReader);
+    FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
 
     // MatchAllDocsQuery is for "browsing" (counts facets
     // for all non-deleted docs in the index); normally
@@ -101,20 +104,31 @@ public class TestDemoFacets extends Luce
     List<FacetResult> results = c.getFacetResults();
     assertEquals(2, results.size());
     assertEquals("Publish Date (5)\n  2012 (2)\n  2010 (2)\n  1999 (1)\n",
-                 toSimpleString(results.get(0)));
+        FacetTestUtils.toSimpleString(results.get(0)));
     assertEquals("Author (5)\n  Lisa (2)\n  Frank (1)\n  Susan (1)\n  Bob (1)\n",
-                 toSimpleString(results.get(1)));
+        FacetTestUtils.toSimpleString(results.get(1)));
 
     
     // Now user drills down on Publish Date/2010:
     fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
     Query q2 = DrillDown.query(fsp, new MatchAllDocsQuery(), new CategoryPath("Publish Date/2010", '/'));
-    c = new FacetsCollector(fsp, searcher.getIndexReader(), taxoReader);
+    c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
     searcher.search(q2, c);
     results = c.getFacetResults();
     assertEquals(1, results.size());
     assertEquals("Author (2)\n  Lisa (1)\n  Bob (1)\n",
-                 toSimpleString(results.get(0)));
+        FacetTestUtils.toSimpleString(results.get(0)));
+
+    // Smoke test PrintTaxonomyStats:
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    PrintTaxonomyStats.printStats(taxoReader, new PrintStream(bos, false, "UTF-8"), true);
+    String result = bos.toString("UTF-8");
+    assertTrue(result.indexOf("/Author: 4 immediate children; 5 total categories") != -1);
+    assertTrue(result.indexOf("/Publish Date: 3 immediate children; 12 total categories") != -1);
+    // Make sure at least a few nodes of the tree came out:
+    assertTrue(result.indexOf("  /1999") != -1);
+    assertTrue(result.indexOf("  /2012") != -1);
+    assertTrue(result.indexOf("      /20") != -1);
 
     taxoReader.close();
     searcher.getIndexReader().close();
@@ -122,16 +136,4 @@ public class TestDemoFacets extends Luce
     taxoDir.close();
   }
 
-  private String toSimpleString(FacetResult fr) {
-    StringBuilder sb = new StringBuilder();
-    toSimpleString(0, sb, fr.getFacetResultNode(), "");
-    return sb.toString();
-  }
-
-  private void toSimpleString(int depth, StringBuilder sb, FacetResultNode node, String indent) {
-    sb.append(indent + node.getLabel().components[depth] + " (" + (int) node.getValue() + ")\n");
-    for(FacetResultNode childNode : node.getSubResults()) {
-      toSimpleString(depth+1, sb, childNode, indent + "  ");
-    }
-  }
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java Mon Jan 21 19:23:25 2013
@@ -118,8 +118,8 @@ public class TestFacetsAccumulatorWithCo
     FacetResultNode parentResWithComp = countResWithComplement.get(0).getFacetResultNode();
     FacetResultNode parentResNoComp = countResWithComplement.get(0).getFacetResultNode();
     
-    assertEquals("Wrong number of top count aggregated categories with complement!",3,parentResWithComp.getNumSubResults());
-    assertEquals("Wrong number of top count aggregated categories no complement!",3,parentResNoComp.getNumSubResults());
+    assertEquals("Wrong number of top count aggregated categories with complement!",3,parentResWithComp.subResults.size());
+    assertEquals("Wrong number of top count aggregated categories no complement!",3,parentResNoComp.subResults.size());
     
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java Mon Jan 21 19:23:25 2013
@@ -3,7 +3,7 @@ package org.apache.lucene.facet.search;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.document.StringField;
@@ -53,7 +53,7 @@ public class TestFacetsCollector extends
 
     TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(taxoDir);
     IndexWriter iw = new IndexWriter(indexDir, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, new KeywordAnalyzer()));
+        TEST_VERSION_CURRENT, new MockAnalyzer(random())));
 
     FacetFields facetFields = new FacetFields(taxonomyWriter);
     for(int i = atLeast(2000); i > 0; --i) {
@@ -71,12 +71,12 @@ public class TestFacetsCollector extends
     DirectoryReader r = DirectoryReader.open(indexDir);
     DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
     
-    FacetsCollector fc = new FacetsCollector(sParams, r, taxo);
+    FacetsCollector fc = FacetsCollector.create(sParams, r, taxo);
     TopScoreDocCollector topDocs = TopScoreDocCollector.create(10, false);
     new IndexSearcher(r).search(new MatchAllDocsQuery(), MultiCollector.wrap(fc, topDocs));
     
     List<FacetResult> res = fc.getFacetResults();
-    double value = res.get(0).getFacetResultNode().getValue();
+    double value = res.get(0).getFacetResultNode().value;
     double expected = topDocs.topDocs().getMaxScore() * r.numDocs();
     assertEquals(expected, value, 1E-10);
     

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java Mon Jan 21 19:23:25 2013
@@ -271,7 +271,7 @@ public class TestMultipleCategoryLists e
 
     FacetResult results = res.get(0);
     FacetResultNode resNode = results.getFacetResultNode();
-    Iterable<? extends FacetResultNode> subResults = resNode.getSubResults();
+    Iterable<? extends FacetResultNode> subResults = resNode.subResults;
     Iterator<? extends FacetResultNode> subIter = subResults.iterator();
 
     checkResult(resNode, "Band", 5.0);
@@ -280,7 +280,7 @@ public class TestMultipleCategoryLists e
 
     results = res.get(1);
     resNode = results.getFacetResultNode();
-    subResults = resNode.getSubResults();
+    subResults = resNode.subResults;
     subIter = subResults.iterator();
 
     checkResult(resNode, "Band", 5.0);
@@ -294,7 +294,7 @@ public class TestMultipleCategoryLists e
 
     results = res.get(2);
     resNode = results.getFacetResultNode();
-    subResults = resNode.getSubResults();
+    subResults = resNode.subResults;
     subIter = subResults.iterator();
 
     checkResult(resNode, "Author", 3.0);
@@ -304,7 +304,7 @@ public class TestMultipleCategoryLists e
 
     results = res.get(3);
     resNode = results.getFacetResultNode();
-    subResults = resNode.getSubResults();
+    subResults = resNode.subResults;
     subIter = subResults.iterator();
 
     checkResult(resNode, "Band/Rock & Pop", 4.0);
@@ -334,7 +334,7 @@ public class TestMultipleCategoryLists e
     FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
 
     // perform documents search and facets accumulation
-    FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, ir, tr);
+    FacetsCollector facetsCollector = FacetsCollector.create(facetSearchParams, ir, tr);
     searcher.search(q, MultiCollector.wrap(topDocsCollector, facetsCollector));
     return facetsCollector;
   }
@@ -350,8 +350,8 @@ public class TestMultipleCategoryLists e
   }
 
   private static void checkResult(FacetResultNode sub, String label, double value) {
-    assertEquals("Label of subresult " + sub.getLabel() + " was incorrect", label, sub.getLabel().toString());
-    assertEquals("Value for " + sub.getLabel() + " subresult was incorrect", value, sub.getValue(), 0.0);
+    assertEquals("Label of subresult " + sub.label + " was incorrect", label, sub.label.toString());
+    assertEquals("Value for " + sub.label + " subresult was incorrect", value, sub.value, 0.0);
   }
 
 }
\ No newline at end of file

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestSameRequestAccumulation.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestSameRequestAccumulation.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestSameRequestAccumulation.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestSameRequestAccumulation.java Mon Jan 21 19:23:25 2013
@@ -44,7 +44,7 @@ public class TestSameRequestAccumulation
     final CountFacetRequest facetRequest = new CountFacetRequest(new CategoryPath("root"), 10);
     FacetSearchParams fsp = new FacetSearchParams(facetRequest);
     
-    FacetsCollector fc = new FacetsCollector(fsp, indexReader, taxoReader);
+    FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
     searcher.search(new MatchAllDocsQuery(), fc);
     
     final String expected = fc.getFacetResults().get(0).toString();
@@ -53,9 +53,9 @@ public class TestSameRequestAccumulation
     fsp = new FacetSearchParams(facetRequest, facetRequest, new CountFacetRequest(new CategoryPath("root"), 10));
 
     // make sure the search params holds 3 requests now
-    assertEquals(3, fsp.getFacetRequests().size());
+    assertEquals(3, fsp.facetRequests.size());
     
-    fc = new FacetsCollector(fsp, indexReader, taxoReader);
+    fc = FacetsCollector.create(fsp, indexReader, taxoReader);
     searcher.search(new MatchAllDocsQuery(), fc);
     List<FacetResult> actual = fc.getFacetResults();
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java Mon Jan 21 19:23:25 2013
@@ -89,10 +89,8 @@ public class TestScoredDocIdCollector ex
     FacetResultNode parentCountRes = countRes.get(0).getFacetResultNode();
     FacetResultNode parentScoreRes = scoreRes.get(0).getFacetResultNode();
 
-    assertEquals("Wrong number of top count aggregated categories!", 3,
-        parentCountRes.getNumSubResults());
-    assertEquals("Wrong number of top score aggregated categories!", 3,
-        parentScoreRes.getNumSubResults());
+    assertEquals("Wrong number of top count aggregated categories!", 3, parentCountRes.subResults.size());
+    assertEquals("Wrong number of top score aggregated categories!", 3, parentScoreRes.subResults.size());
 
     // rely on that facet value is computed as doc-score, and
     // accordingly compare values of the two top-category results.
@@ -101,12 +99,8 @@ public class TestScoredDocIdCollector ex
     FacetResultNode[] scoreResNodes = resultNodesAsArray(parentScoreRes);
 
     for (int i = 0; i < scoreResNodes.length; i++) {
-      assertEquals("Ordinals differ!", 
-          countResNodes[i].getOrdinal(), scoreResNodes[i].getOrdinal());
-      assertEquals("Wrong scores!", 
-          constScore * countResNodes[i].getValue(),
-          scoreResNodes[i].getValue(), 
-          Double.MIN_VALUE);
+      assertEquals("Ordinals differ!", countResNodes[i].ordinal, scoreResNodes[i].ordinal);
+      assertEquals("Wrong scores!", constScore * countResNodes[i].value, scoreResNodes[i].value, Double.MIN_VALUE);
     }
   }
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java Mon Jan 21 19:23:25 2013
@@ -1,7 +1,6 @@
 package org.apache.lucene.facet.search;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -102,24 +101,22 @@ public class TestStandardFacetsAccumulat
     
     // search for "f:a", only segments 1 and 3 should match results
     Query q = new TermQuery(new Term("f", "a"));
-    ArrayList<FacetRequest> requests = new ArrayList<FacetRequest>(1);
-    CountFacetRequest countNoComplements = new CountFacetRequest(new CategoryPath("A"), 10) {
+    FacetRequest countNoComplements = new CountFacetRequest(new CategoryPath("A"), 10) {
       @Override
       public boolean supportsComplements() {
         return false; // disable complements
       }
     };
-    requests.add(countNoComplements);
-    FacetSearchParams fsp = new FacetSearchParams(requests, fip);
-    FacetsCollector fc = new FacetsCollector(fsp , indexReader, taxoReader);
+    FacetSearchParams fsp = new FacetSearchParams(fip, countNoComplements);
+    FacetsCollector fc = new StandardFacetsCollector(fsp , indexReader, taxoReader);
     indexSearcher.search(q, fc);
     List<FacetResult> results = fc.getFacetResults();
     assertEquals("received too many facet results", 1, results.size());
     FacetResultNode frn = results.get(0).getFacetResultNode();
-    assertEquals("wrong weight for \"A\"", 4, (int) frn.getValue());
-    assertEquals("wrong number of children", 2, frn.getNumSubResults());
-    for (FacetResultNode node : frn.getSubResults()) {
-      assertEquals("wrong weight for child " + node.getLabel(), 2, (int) node.getValue());
+    assertEquals("wrong weight for \"A\"", 4, (int) frn.value);
+    assertEquals("wrong number of children", 2, frn.subResults.size());
+    for (FacetResultNode node : frn.subResults) {
+      assertEquals("wrong weight for child " + node.label, 2, (int) node.value);
     }
     IOUtils.close(indexReader, taxoReader);
     

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java Mon Jan 21 19:23:25 2013
@@ -165,7 +165,7 @@ public class TestTopKInEachNodeResultHan
       facetRequests.add(cfrb20);
       FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
       
-      FacetArrays facetArrays = new FacetArrays(PartitionsUtils.partitionSize(facetSearchParams.getFacetIndexingParams(), tr));
+      FacetArrays facetArrays = new FacetArrays(PartitionsUtils.partitionSize(facetSearchParams.indexingParams, tr));
       FacetsAccumulator fctExtrctr = new StandardFacetsAccumulator(facetSearchParams, is.getIndexReader(), tr, facetArrays);
       fctExtrctr.setComplementThreshold(FacetsAccumulator.DISABLE_COMPLEMENT);
       long start = System.currentTimeMillis();
@@ -181,40 +181,40 @@ public class TestTopKInEachNodeResultHan
       boolean hasDoctor = "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(9, fr.getNumValidDescendants());
       FacetResultNode parentRes = fr.getFacetResultNode();
-      assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
+      assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
       // two nodes sorted by descending values: a/b with 8  and a/c with 6
       // a/b has residue 2 and two children a/b/2 with value 3, and a/b/1 with value 2. 
       // a/c has residue 0, and one child a/c/1 with value 1.
       double [] expectedValues0 = { 8.0, 2.0, 3.0, 0.0, 2.0, 0.0, 6.0, 0.0, 1.0, 0.0 };
       int i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues0[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(expectedValues0[i++], node.getResidue(), Double.MIN_VALUE);
-        for (FacetResultNode node2 : node.getSubResults()) {
-          assertEquals(expectedValues0[i++], node2.getValue(), Double.MIN_VALUE);
-          assertEquals(expectedValues0[i++], node2.getResidue(), Double.MIN_VALUE);
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues0[i++], node.value, Double.MIN_VALUE);
+        assertEquals(expectedValues0[i++], node.residue, Double.MIN_VALUE);
+        for (FacetResultNode node2 : node.subResults) {
+          assertEquals(expectedValues0[i++], node2.value, Double.MIN_VALUE);
+          assertEquals(expectedValues0[i++], node2.residue, Double.MIN_VALUE);
         }
       }
 
       // now just change the value of the first child of the root to 5, and then rearrange
       // expected are: first a/c of value 6 and residue 0, and one child a/c/1 with value 1
       // then a/b with value 5 and residue 2, and both children: a/b/2 with value 3, and a/b/1 with value 2.
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        node.setValue(5.0);
+      for (FacetResultNode node : parentRes.subResults) {
+        node.value = 5.0;
         break;
       }
       // now rearrange
       double [] expectedValues00 = { 6.0, 0.0, 1.0, 0.0, 5.0, 2.0, 3.0, 0.0, 2.0, 0.0 };
       fr = cfra23.createFacetResultsHandler(tr).rearrangeFacetResult(fr);
       i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues00[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(expectedValues00[i++], node.getResidue(), Double.MIN_VALUE);
-        for (FacetResultNode node2 : node.getSubResults()) {
-          assertEquals(expectedValues00[i++], node2.getValue(), Double.MIN_VALUE);
-          assertEquals(expectedValues00[i++], node2.getResidue(), Double.MIN_VALUE);
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues00[i++], node.value, Double.MIN_VALUE);
+        assertEquals(expectedValues00[i++], node.residue, Double.MIN_VALUE);
+        for (FacetResultNode node2 : node.subResults) {
+          assertEquals(expectedValues00[i++], node2.value, Double.MIN_VALUE);
+          assertEquals(expectedValues00[i++], node2.residue, Double.MIN_VALUE);
         }
       }
 
@@ -222,19 +222,19 @@ public class TestTopKInEachNodeResultHan
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(9, fr.getNumValidDescendants());
       parentRes = fr.getFacetResultNode();
-      assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
+      assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
       // two nodes sorted by descending values: a/b with 8  and a/c with 6
       // a/b has residue 2 and two children a/b/2 with value 3, and a/b/1 with value 2. 
       // a/c has residue 0, and one child a/c/1 with value 1.
       i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues0[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(expectedValues0[i++], node.getResidue(), Double.MIN_VALUE);
-        for (FacetResultNode node2 : node.getSubResults()) {
-          assertEquals(expectedValues0[i++], node2.getValue(), Double.MIN_VALUE);
-          assertEquals(expectedValues0[i++], node2.getResidue(), Double.MIN_VALUE);
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues0[i++], node.value, Double.MIN_VALUE);
+        assertEquals(expectedValues0[i++], node.residue, Double.MIN_VALUE);
+        for (FacetResultNode node2 : node.subResults) {
+          assertEquals(expectedValues0[i++], node2.value, Double.MIN_VALUE);
+          assertEquals(expectedValues0[i++], node2.residue, Double.MIN_VALUE);
         }
       }
 
@@ -242,70 +242,70 @@ public class TestTopKInEachNodeResultHan
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(4, fr.getNumValidDescendants(), 4);
       parentRes = fr.getFacetResultNode();
-      assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
+      assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
       // two nodes sorted by descending values: 
       // a/b with value 8 and residue 0 (because no children considered),  
       //  and a/c with value 6 and residue 0 (because no children considered)
       double [] expectedValues2 = { 8.0, 0.0, 6.0, 0.0 };
       i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues2[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(expectedValues2[i++], node.getResidue(), Double.MIN_VALUE);
-        assertEquals(node.getNumSubResults(), 0);
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues2[i++], node.value, Double.MIN_VALUE);
+        assertEquals(expectedValues2[i++], node.residue, Double.MIN_VALUE);
+        assertEquals(node.subResults.size(), 0);
       }
       
       fr = facetResults.get(3); // a/b, depth=3, K=2
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(4, fr.getNumValidDescendants());
       parentRes = fr.getFacetResultNode();
-      assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
+      assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
       double [] expectedValues3 = { 3.0, 2.0 };
       i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
-        assertEquals(0, node.getNumSubResults());
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+        assertEquals(0.0, node.residue, Double.MIN_VALUE);
+        assertEquals(0, node.subResults.size());
       }
 
       fr = facetResults.get(4); // a/b, depth=2, K=2
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(4, fr.getNumValidDescendants());
       parentRes = fr.getFacetResultNode();
-      assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
-      i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
-        assertEquals(0, node.getNumSubResults());
+      assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
+      i = 0;
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+        assertEquals(0.0, node.residue, Double.MIN_VALUE);
+        assertEquals(0, node.subResults.size());
       }
 
       fr = facetResults.get(5); // a/b, depth=1, K=2
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(4, fr.getNumValidDescendants());
       parentRes = fr.getFacetResultNode();
-      assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(2, parentRes.getNumSubResults());
-      i = 0;
-      for (FacetResultNode node : parentRes.getSubResults()) {
-        assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
-        assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
-        assertEquals(0, node.getNumSubResults());
+      assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(2, parentRes.subResults.size());
+      i = 0;
+      for (FacetResultNode node : parentRes.subResults) {
+        assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+        assertEquals(0.0, node.residue, Double.MIN_VALUE);
+        assertEquals(0, node.subResults.size());
       }
       
       fr = facetResults.get(6); // a/b, depth=0, K=2
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
       assertEquals(0, fr.getNumValidDescendants()); // 0 descendants but rootnode
       parentRes = fr.getFacetResultNode();
-      assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
-      assertEquals(0.0, parentRes.getResidue(), Double.MIN_VALUE);
-      assertEquals(0, parentRes.getNumSubResults());
+      assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+      assertEquals(0.0, parentRes.residue, Double.MIN_VALUE);
+      assertEquals(0, parentRes.subResults.size());
       hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
 
       // doctor, depth=1, K=2

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java Mon Jan 21 19:23:25 2013
@@ -89,7 +89,7 @@ public class TestTopKResultsHandler exte
       // do different facet counts and compare to control
       FacetSearchParams sParams = getFacetSearchParams(facetRequests, getFacetIndexingParams(partitionSize));
 
-      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
+      FacetsCollector fc = new StandardFacetsCollector(sParams, indexReader, taxoReader) {
         @Override
         protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
           FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
@@ -99,52 +99,46 @@ public class TestTopKResultsHandler exte
       };
       
       searcher.search(new MatchAllDocsQuery(), fc);
-      long start = System.currentTimeMillis();
       List<FacetResult> facetResults = fc.getFacetResults();
-      long end = System.currentTimeMillis();
-
-      if (VERBOSE) {
-        System.out.println("Time: " + (end - start));
-      }
 
       FacetResult fr = facetResults.get(0);
       FacetResultNode parentRes = fr.getFacetResultNode();
-      assertEquals(13.0, parentRes.getValue(), Double.MIN_VALUE);
+      assertEquals(13.0, parentRes.value, Double.MIN_VALUE);
       FacetResultNode[] frn = resultNodesAsArray(parentRes);
-      assertEquals(7.0, frn[0].getValue(), Double.MIN_VALUE);
-      assertEquals(6.0, frn[1].getValue(), Double.MIN_VALUE);
+      assertEquals(7.0, frn[0].value, Double.MIN_VALUE);
+      assertEquals(6.0, frn[1].value, Double.MIN_VALUE);
 
       fr = facetResults.get(1);
       parentRes = fr.getFacetResultNode();
-      assertEquals(13.0, parentRes.getValue(), Double.MIN_VALUE);
+      assertEquals(13.0, parentRes.value, Double.MIN_VALUE);
       frn = resultNodesAsArray(parentRes);
-      assertEquals(7.0, frn[0].getValue(), Double.MIN_VALUE);
-      assertEquals(6.0, frn[1].getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, frn[2].getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, frn[3].getValue(), Double.MIN_VALUE);
-      assertEquals(1.0, frn[4].getValue(), Double.MIN_VALUE);
-      assertEquals(1.0, frn[5].getValue(), Double.MIN_VALUE);
+      assertEquals(7.0, frn[0].value, Double.MIN_VALUE);
+      assertEquals(6.0, frn[1].value, Double.MIN_VALUE);
+      assertEquals(2.0, frn[2].value, Double.MIN_VALUE);
+      assertEquals(2.0, frn[3].value, Double.MIN_VALUE);
+      assertEquals(1.0, frn[4].value, Double.MIN_VALUE);
+      assertEquals(1.0, frn[5].value, Double.MIN_VALUE);
 
       fr = facetResults.get(2);
       parentRes = fr.getFacetResultNode();
-      assertEquals(7.0, parentRes.getValue(), Double.MIN_VALUE);
+      assertEquals(7.0, parentRes.value, Double.MIN_VALUE);
       frn = resultNodesAsArray(parentRes);
-      assertEquals(2.0, frn[0].getValue(), Double.MIN_VALUE);
-      assertEquals(2.0, frn[1].getValue(), Double.MIN_VALUE);
-      assertEquals(1.0, frn[2].getValue(), Double.MIN_VALUE);
-      assertEquals(1.0, frn[3].getValue(), Double.MIN_VALUE);
+      assertEquals(2.0, frn[0].value, Double.MIN_VALUE);
+      assertEquals(2.0, frn[1].value, Double.MIN_VALUE);
+      assertEquals(1.0, frn[2].value, Double.MIN_VALUE);
+      assertEquals(1.0, frn[3].value, Double.MIN_VALUE);
 
       fr = facetResults.get(3);
       parentRes = fr.getFacetResultNode();
-      assertEquals(2.0, parentRes.getValue(), Double.MIN_VALUE);
+      assertEquals(2.0, parentRes.value, Double.MIN_VALUE);
       frn = resultNodesAsArray(parentRes);
       assertEquals(0, frn.length);
 
       fr = facetResults.get(4);
       parentRes = fr.getFacetResultNode();
-      assertEquals(6.0, parentRes.getValue(), Double.MIN_VALUE);
+      assertEquals(6.0, parentRes.value, Double.MIN_VALUE);
       frn = resultNodesAsArray(parentRes);
-      assertEquals(1.0, frn[0].getValue(), Double.MIN_VALUE);
+      assertEquals(1.0, frn[0].value, Double.MIN_VALUE);
       closeAll();
     }
   }
@@ -159,10 +153,10 @@ public class TestTopKResultsHandler exte
 
       // do different facet counts and compare to control
       CategoryPath path = new CategoryPath("a", "b");
-      FacetSearchParams sParams = getFacetSearchParams(
-          getFacetIndexingParams(partitionSize), new CountFacetRequest(path, Integer.MAX_VALUE));
+      FacetSearchParams sParams = getFacetSearchParams(getFacetIndexingParams(partitionSize), 
+          new CountFacetRequest(path, Integer.MAX_VALUE));
 
-      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader) {
+      FacetsCollector fc = new StandardFacetsCollector(sParams, indexReader, taxoReader) {
         @Override
         protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
           FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
@@ -172,13 +166,7 @@ public class TestTopKResultsHandler exte
       };
       
       searcher.search(new MatchAllDocsQuery(), fc);
-      long start = System.currentTimeMillis();
       List<FacetResult> results = fc.getFacetResults();
-      long end = System.currentTimeMillis();
-
-      if (VERBOSE) {
-        System.out.println("Time: " + (end - start));
-      }
 
       assertEquals("Should only be one result as there's only one request", 1, results.size());
       FacetResult res = results.get(0);
@@ -188,7 +176,7 @@ public class TestTopKResultsHandler exte
       FacetSearchParams sParams2 = getFacetSearchParams(
           getFacetIndexingParams(partitionSize), new CountFacetRequest(path, Integer.MAX_VALUE));
 
-      FacetsCollector fc2 = new FacetsCollector(sParams2, indexReader, taxoReader) {
+      FacetsCollector fc2 = new StandardFacetsCollector(sParams2, indexReader, taxoReader) {
         @Override
         protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader, TaxonomyReader taxonomyReader) {
           FacetsAccumulator fa = new StandardFacetsAccumulator(facetSearchParams, indexReader, taxonomyReader);
@@ -226,18 +214,12 @@ public class TestTopKResultsHandler exte
           getFacetIndexingParams(partitionSize),
           new CountFacetRequest(path, 10));
 
-      FacetsCollector fc = new FacetsCollector(sParams, indexReader, taxoReader);
+      FacetsCollector fc = FacetsCollector.create(sParams, indexReader, taxoReader);
       
       searcher.search(new MatchAllDocsQuery(), fc);
       
-      long start = System.currentTimeMillis();
       List<FacetResult> facetResults = fc.getFacetResults();
-      long end = System.currentTimeMillis();
       
-      if (VERBOSE) {
-        System.out.println("Time: " + (end - start));
-      }
-
       assertEquals("Shouldn't have found anything for a FacetRequest "
           + "of a facet that doesn't exist in the index.", 0, facetResults.size());
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java Mon Jan 21 19:23:25 2013
@@ -4,15 +4,14 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.Query;
-import org.junit.Test;
-
 import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.junit.Test;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -37,7 +36,7 @@ public class TestTopKResultsHandlerRando
       throws IOException {
     Query q = new MatchAllDocsQuery();
     FacetSearchParams facetSearchParams = searchParamsWithRequests(numResults, partitionSize);
-    FacetsCollector fc = new FacetsCollector(facetSearchParams, indexReader, taxoReader) {
+    FacetsCollector fc = new StandardFacetsCollector(facetSearchParams, indexReader, taxoReader) {
       @Override
       protected FacetsAccumulator initFacetsAccumulator(
           FacetSearchParams facetSearchParams, IndexReader indexReader,
@@ -88,15 +87,15 @@ public class TestTopKResultsHandlerRando
       int k = 0;
       for (FacetResult fr : allFacetResults) {
         FacetResultNode topResNode = fr.getFacetResultNode();
-        maxNumNodes = Math.max(maxNumNodes, topResNode.getNumSubResults());
+        maxNumNodes = Math.max(maxNumNodes, topResNode.subResults.size());
         int prevCount = Integer.MAX_VALUE;
         int pos = 0;
-        for (FacetResultNode frn: topResNode.getSubResults()) {
-          assertTrue("wrong counts order: prev="+prevCount+" curr="+frn.getValue(), prevCount>=frn.getValue());
-          prevCount = (int) frn.getValue();
-          String key = k+"--"+frn.getLabel()+"=="+frn.getValue();
+        for (FacetResultNode frn: topResNode.subResults) {
+          assertTrue("wrong counts order: prev="+prevCount+" curr="+frn.value, prevCount>=frn.value);
+          prevCount = (int) frn.value;
+          String key = k+"--"+frn.label+"=="+frn.value;
           if (VERBOSE) {
-            System.out.println(frn.getLabel() + " - " + frn.getValue() + "  "+key+"  "+pos);
+            System.out.println(frn.label + " - " + frn.value + "  "+key+"  "+pos);
           }
           all.put(key, pos++); // will use this later to verify order of sub-results
         }
@@ -113,12 +112,12 @@ public class TestTopKResultsHandlerRando
         k = 0;
         for (FacetResult fr : someResults) {
           FacetResultNode topResNode = fr.getFacetResultNode();
-          assertTrue("too many results: n="+n+" but got "+topResNode.getNumSubResults(), n>=topResNode.getNumSubResults());
+          assertTrue("too many results: n="+n+" but got "+topResNode.subResults.size(), n>=topResNode.subResults.size());
           int pos = 0;
-          for (FacetResultNode frn: topResNode.getSubResults()) {
-            String key = k+"--"+frn.getLabel()+"=="+frn.getValue();
+          for (FacetResultNode frn: topResNode.subResults) {
+            String key = k+"--"+frn.label+"=="+frn.value;
             if (VERBOSE) {
-              System.out.println(frn.getLabel() + " - " + frn.getValue() + "  "+key+"  "+pos);
+              System.out.println(frn.label + " - " + frn.value + "  "+key+"  "+pos);
             }
             Integer origPos = all.get(key);
             assertNotNull("missing in all results: "+frn,origPos);

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java Mon Jan 21 19:23:25 2013
@@ -226,9 +226,9 @@ public class TestTotalFacetCountsCache e
       FacetResult result = results.get(i);
       assertNotNull("Result should not be null", result);
       FacetResultNode resNode = result.getFacetResultNode();
-      assertEquals("Invalid label", expLabels[i], resNode.getLabel().toString());
-      assertEquals("Invalid value", expValues[i], resNode.getValue(), 0.0);
-      assertEquals("Invalid number of subresults", 0, resNode.getNumSubResults());
+      assertEquals("Invalid label", expLabels[i], resNode.label.toString());
+      assertEquals("Invalid value", expValues[i], resNode.value, 0.0);
+      assertEquals("Invalid number of subresults", 0, resNode.subResults.size());
     }
     // we're done, close the index reader and the taxonomy.
     slowIndexReader.close();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/associations/AssociationsFacetRequestTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/associations/AssociationsFacetRequestTest.java?rev=1436566&r1=1436565&r2=1436566&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/associations/AssociationsFacetRequestTest.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/test/org/apache/lucene/facet/search/associations/AssociationsFacetRequestTest.java Mon Jan 21 19:23:25 2013
@@ -110,7 +110,7 @@ public class AssociationsFacetRequestTes
     
     Query q = new MatchAllDocsQuery();
 
-    FacetsCollector fc = new FacetsCollector(fsp, reader, taxo);
+    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
     
     IndexSearcher searcher = newSearcher(reader);
     searcher.search(q, fc);
@@ -118,8 +118,8 @@ public class AssociationsFacetRequestTes
     
     assertNotNull("No results!",res);
     assertEquals("Wrong number of results!",2, res.size());
-    assertEquals("Wrong count for category 'a'!",200, (int) res.get(0).getFacetResultNode().getValue());
-    assertEquals("Wrong count for category 'b'!",150, (int) res.get(1).getFacetResultNode().getValue());
+    assertEquals("Wrong count for category 'a'!",200, (int) res.get(0).getFacetResultNode().value);
+    assertEquals("Wrong count for category 'b'!",150, (int) res.get(1).getFacetResultNode().value);
     
     taxo.close();
   }
@@ -135,7 +135,7 @@ public class AssociationsFacetRequestTes
     
     Query q = new MatchAllDocsQuery();
 
-    FacetsCollector fc = new FacetsCollector(fsp, reader, taxo);
+    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
     
     IndexSearcher searcher = newSearcher(reader);
     searcher.search(q, fc);
@@ -143,8 +143,8 @@ public class AssociationsFacetRequestTes
     
     assertNotNull("No results!",res);
     assertEquals("Wrong number of results!",2, res.size());
-    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(0).getFacetResultNode().getValue(), 0.00001);
-    assertEquals("Wrong count for category 'b'!",10f, (float) res.get(1).getFacetResultNode().getValue(), 0.00001);
+    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(0).getFacetResultNode().value, 0.00001);
+    assertEquals("Wrong count for category 'b'!",10f, (float) res.get(1).getFacetResultNode().value, 0.00001);
     
     taxo.close();
   }  
@@ -165,7 +165,7 @@ public class AssociationsFacetRequestTes
     
     Query q = new MatchAllDocsQuery();
 
-    FacetsCollector fc = new FacetsCollector(fsp, reader, taxo);
+    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
     
     IndexSearcher searcher = newSearcher(reader);
     searcher.search(q, fc);



Mime
View raw message