You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/01/08 04:40:37 UTC

svn commit: r1430130 [9/27] - in /lucene/dev/branches/lucene4547: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/ dev-tools/maven/ dev-tools/maven/solr/ dev-tools/maven/solr/contrib/analysis-extras/ dev-tools/maven/solr/contrib/cluster...

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationSearcher.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationSearcher.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationSearcher.java Tue Jan  8 03:40:16 2013
@@ -7,8 +7,8 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.store.Directory;
 
 import org.apache.lucene.facet.example.simple.SimpleSearcher;
-import org.apache.lucene.facet.search.params.association.AssociationFloatSumFacetRequest;
-import org.apache.lucene.facet.search.params.association.AssociationIntSumFacetRequest;
+import org.apache.lucene.facet.search.params.associations.AssociationFloatSumFacetRequest;
+import org.apache.lucene.facet.search.params.associations.AssociationIntSumFacetRequest;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
@@ -49,8 +49,7 @@ public class AssociationSearcher {
     AssociationIntSumFacetRequest facetRequest = new AssociationIntSumFacetRequest(
         new CategoryPath("tags"), 10);
     
-    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo,
-        AssociationUtils.assocIndexingParams, facetRequest);
+    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo, null, facetRequest);
     
     // close readers
     taxo.close();
@@ -69,8 +68,7 @@ public class AssociationSearcher {
     AssociationFloatSumFacetRequest facetRequest = new AssociationFloatSumFacetRequest(
         new CategoryPath("genre"), 10);
     
-    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo,
-        AssociationUtils.assocIndexingParams, facetRequest);
+    List<FacetResult> res = SimpleSearcher.searchWithRequest(indexReader, taxo, null, facetRequest);
     
     // close readers
     taxo.close();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java Tue Jan  8 03:40:16 2013
@@ -1,10 +1,8 @@
 package org.apache.lucene.facet.example.association;
 
-import org.apache.lucene.facet.enhancements.association.AssociationEnhancement;
-import org.apache.lucene.facet.enhancements.association.AssociationFloatProperty;
-import org.apache.lucene.facet.enhancements.association.AssociationIntProperty;
-import org.apache.lucene.facet.enhancements.association.AssociationProperty;
-import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
+import org.apache.lucene.facet.associations.CategoryAssociation;
+import org.apache.lucene.facet.associations.CategoryFloatAssociation;
+import org.apache.lucene.facet.associations.CategoryIntAssociation;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
@@ -47,33 +45,26 @@ public class AssociationUtils {
     }
   };
 
-  public static AssociationProperty[][] associations = {
+  public static CategoryAssociation[][] associations = {
     // Doc #1 associations
     {
       /* 3 occurrences for tag 'lucene' */
-      new AssociationIntProperty(3), 
+      new CategoryIntAssociation(3), 
       /* 87% confidence level of genre 'computing' */
-      new AssociationFloatProperty(0.87f)
+      new CategoryFloatAssociation(0.87f)
     },
     
     // Doc #2 associations
     {
       /* 1 occurrence for tag 'lucene' */
-      new AssociationIntProperty(1),
+      new CategoryIntAssociation(1),
       /* 2 occurrences for tag 'solr' */
-      new AssociationIntProperty(2),
+      new CategoryIntAssociation(2),
       /* 75% confidence level of genre 'computing' */
-      new AssociationFloatProperty(0.75f),
+      new CategoryFloatAssociation(0.75f),
       /* 34% confidence level of genre 'software' */
-      new AssociationFloatProperty(0.34f),
+      new CategoryFloatAssociation(0.34f),
     }
   };
 
-  /**
-   * Indexing Params: the indexing params to use when dealing with
-   * associations.
-   */
-  public static final DefaultEnhancementsIndexingParams assocIndexingParams = 
-    new DefaultEnhancementsIndexingParams(new AssociationEnhancement());
-
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java Tue Jan  8 03:40:16 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,7 +86,7 @@ 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();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java Tue Jan  8 03:40:16 2013
@@ -1,27 +1,28 @@
 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.index.Term;
+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 +75,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(new Term("$Digits", "Zero")));
+    paramsMap.put(new CategoryPath("1"), new CategoryListParams(new Term("$Digits", "One")));
+    paramsMap.put(new CategoryPath("2"), new CategoryListParams(new Term("$Digits", "Two")));
+    paramsMap.put(new CategoryPath("3"), new CategoryListParams(new Term("$Digits", "Three")));
+    paramsMap.put(new CategoryPath("4"), new CategoryListParams(new Term("$Digits", "Four")));
+    paramsMap.put(new CategoryPath("5"), new CategoryListParams(new Term("$Digits", "Five")));
+    MULTI_IPARAMS = new PerDimensionIndexingParams(paramsMap);
   }
   
   /**
@@ -164,10 +161,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 +171,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/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java Tue Jan  8 03:40:16 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/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java Tue Jan  8 03:40:16 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/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java Tue Jan  8 03:40:16 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,7 +132,7 @@ public class SimpleSearcher {
   public static List<FacetResult> searchWithDrillDown(IndexReader indexReader,
       TaxonomyReader taxoReader) throws Exception {
 
-    final FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
+    final FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
     
     // base query the user is interested in
     Query baseQuery = new TermQuery(new Term(SimpleUtils.TEXT, "white"));

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html Tue Jan  8 03:40:16 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

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java Tue Jan  8 03:40:16 2013
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.lucene.facet.index.params.CategoryListParams;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
 import org.apache.lucene.index.AtomicReader;
@@ -71,6 +70,7 @@ import org.apache.lucene.util.encoding.I
  * @lucene.experimental
  */
 public class OrdinalMappingAtomicReader extends FilterAtomicReader {
+  
   private final int[] ordinalMap;
   // a little obtuse: but we dont need to create Term objects this way
   private final Map<String,Map<BytesRef,CategoryListParams>> termMap = 
@@ -82,7 +82,7 @@ public class OrdinalMappingAtomicReader 
    * OrdinalMappingAtomicReader(in, ordinalMap, new DefaultFacetIndexingParams())}
    */
   public OrdinalMappingAtomicReader(AtomicReader in, int[] ordinalMap) {
-    this(in, ordinalMap, new DefaultFacetIndexingParams());
+    this(in, ordinalMap, FacetIndexingParams.ALL_PARENTS);
   }
   
   /**

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelOrdinalPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelOrdinalPolicy.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelOrdinalPolicy.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelOrdinalPolicy.java Tue Jan  8 03:40:16 2013
@@ -46,6 +46,7 @@ public class NonTopLevelOrdinalPolicy im
    *            A relevant taxonomyWriter object, with which ordinals sent to
    *            {@link #shouldAdd(int)} are examined.
    */
+  @Override
   public void init(TaxonomyWriter taxonomyWriter) {
     this.taxonomyWriter = taxonomyWriter;
   }
@@ -55,6 +56,7 @@ public class NonTopLevelOrdinalPolicy im
    * determine if a parent is root, there's a need for
    * {@link TaxonomyWriter#getParent(int)}.
    */
+  @Override
   public boolean shouldAdd(int ordinal) {
     if (ordinal > TaxonomyReader.ROOT_ORDINAL) {
       try {

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelPathPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelPathPolicy.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelPathPolicy.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/NonTopLevelPathPolicy.java Tue Jan  8 03:40:16 2013
@@ -37,7 +37,8 @@ public class NonTopLevelPathPolicy imple
    * Filters out (returns false) CategoryPaths equal or less than
    * {@link TaxonomyReader#ROOT_ORDINAL}. true otherwise.
    */
+  @Override
   public boolean shouldAdd(CategoryPath categoryPath) {
-    return categoryPath.length() >= DEFAULT_MINIMAL_SUBPATH_LENGTH;
+    return categoryPath.length >= DEFAULT_MINIMAL_SUBPATH_LENGTH;
   }
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java Tue Jan  8 03:40:16 2013
@@ -2,7 +2,6 @@ package org.apache.lucene.facet.index.ca
 
 import java.io.Serializable;
 
-import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
 import org.apache.lucene.facet.search.FacetsAccumulator;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
@@ -25,11 +24,9 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * Filtering category ordinals in {@link CategoryParentsStream}, where a given
- * category ordinal is added to the stream, and than its parents are being added
- * one after the other using {@link TaxonomyWriter#getParent(int)}. <br>
- * That loop should have a stop point - the default approach (excluding the
- * ROOT) is implemented in {@link OrdinalPolicy#ALL_PARENTS}.
+ * A policy for adding category parent ordinals to the list of ordinals that are
+ * encoded for a given document. The default {@link #ALL_PARENTS} policy always
+ * adds all parents, where {@link #NO_PARENTS} never adds any parents.
  * 
  * @lucene.experimental
  */

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/PathPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/PathPolicy.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/PathPolicy.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/PathPolicy.java Tue Jan  8 03:40:16 2013
@@ -2,7 +2,7 @@ package org.apache.lucene.facet.index.ca
 
 import java.io.Serializable;
 
-import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
+import org.apache.lucene.facet.index.DrillDownStream;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
@@ -24,7 +24,7 @@ import org.apache.lucene.facet.taxonomy.
 
 /**
  * Determines which {@link CategoryPath categories} should be added as terms to
- * the {@link CategoryParentsStream}. The default approach is implemented by
+ * the {@link DrillDownStream}. The default approach is implemented by
  * {@link #ALL_CATEGORIES}.
  * 
  * @lucene.experimental
@@ -33,12 +33,12 @@ public interface PathPolicy extends Seri
 
   /**
    * A {@link PathPolicy} which adds all {@link CategoryPath} that have at least
-   * one component (i.e. {@link CategoryPath#length()} &gt; 0) to the categories
+   * one component (i.e. {@link CategoryPath#length} &gt; 0) to the categories
    * stream.
    */
   public static final PathPolicy ALL_CATEGORIES = new PathPolicy() {
     @Override
-    public boolean shouldAdd(CategoryPath categoryPath) { return categoryPath.length() > 0; }
+    public boolean shouldAdd(CategoryPath categoryPath) { return categoryPath.length > 0; }
   };
   
   /**

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/package.html?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/package.html (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/package.html Tue Jan  8 03:40:16 2013
@@ -23,7 +23,7 @@
 
 Attachment of 
 {@link org.apache.lucene.facet.taxonomy.CategoryPath CategoryPath}'s 
-or {@link org.apache.lucene.facet.index.attributes.CategoryAttribute CategoryAttribute}'s 
+or {@link org.apache.lucene.facet.associations.CategoryAssociation CategoryAssociation}'s 
 to a given document using a 
 {@link org.apache.lucene.facet.taxonomy.TaxonomyWriter Taxonomy}.
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java Tue Jan  8 03:40:16 2013
@@ -1,9 +1,11 @@
 package org.apache.lucene.facet.index.params;
 
-import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
 import org.apache.lucene.facet.index.categorypolicy.PathPolicy;
+import org.apache.lucene.facet.search.FacetArrays;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
@@ -24,75 +26,202 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * Parameters on how facets are to be written to the index. 
- * For example, which fields and terms are used to refer to the indexed posting list.
- * <P>
- * If non-default parameters were used during indexing, the same parameters
- * must also be passed during faceted search. This requirement is analogous
- * to the requirement during search to know which fields were indexed, and which
- * Analyzer was used on the text.
+ * Defines parameters that are needed for facets indexing. Note that this class
+ * does not have any setters. That's because overriding the default parameters
+ * is considered expert. If you wish to override them, simply extend this class
+ * and override the relevant getter.
+ * 
+ * <p>
+ * <b>NOTE:</b> This class is also used during faceted search in order to e.g.
+ * know which field holds the drill-down terms or the fulltree posting.
+ * Therefore this class should be initialized once and you should refrain from
+ * changing it. Also note that if you make any changes to it (e.g. suddenly
+ * deciding that drill-down terms should be read from a different field) and use
+ * it on an existing index, things may not work as expected.
  * 
  * @lucene.experimental
  */
-public interface FacetIndexingParams extends Serializable {
+public class FacetIndexingParams {
+  
+  // the default CLP, can be a singleton
+  protected static final CategoryListParams DEFAULT_CATEGORY_LIST_PARAMS = new CategoryListParams();
 
   /**
-   * The name of the category-list to put this category in, or null if this
-   * category should not be aggregatable.
-   * <P>
-   * By default, all categories are written to the same category list, but
-   * applications which know in advance that in some situations only parts
-   * of the category hierarchy needs to be counted can divide the categories
-   * into two or more different category lists.
-   * <P>
-   * If null is returned for a category, it means that this category should
-   * not appear in any category list, and thus counts for it cannot be
-   * aggregated. This category can still be used for drill-down, even though
-   * the count for it is not known.
+   * A {@link FacetIndexingParams} which fixes {@link OrdinalPolicy} to
+   * {@link OrdinalPolicy#NO_PARENTS}. This is a singleton equivalent to new
+   * {@link #FacetIndexingParams()}.
    */
-  public CategoryListParams getCategoryListParams(CategoryPath category);
-
+  public static final FacetIndexingParams ALL_PARENTS = new FacetIndexingParams();
+  
   /**
-   * Return info about all category lists in the index.
-   * 
-   * @see #getCategoryListParams(CategoryPath)
+   * The default delimiter with which {@link CategoryPath#components} are
+   * concatenated when written to the index, e.g. as drill-down terms. If you
+   * choose to override it by overiding {@link #getFacetDelimChar()}, you should
+   * make sure that you return a character that's not found in any path
+   * component.
    */
-  public Iterable<CategoryListParams> getAllCategoryListParams();
+  public static final char DEFAULT_FACET_DELIM_CHAR = '\uF749';
+  
+  private final OrdinalPolicy ordinalPolicy = OrdinalPolicy.ALL_PARENTS;
+  private final PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
+  private final int partitionSize = Integer.MAX_VALUE;
 
-  // TODO (Facet): Add special cases of exact/non-exact category term-text
+  protected final CategoryListParams clParams;
 
   /**
-   * Return the drilldown Term-Text which does not need to do any allocations.
-   * The number of chars set is returned.
+   * Initializes new default params. You should use this constructor only if you
+   * intend to override any of the getters, otherwise you can use
+   * {@link #ALL_PARENTS} to save unnecessary object allocations.
+   */
+  public FacetIndexingParams() {
+    this(DEFAULT_CATEGORY_LIST_PARAMS);
+  }
+
+  /** Initializes new params with the given {@link CategoryListParams}. */
+  public FacetIndexingParams(CategoryListParams categoryListParams) {
+    clParams = categoryListParams;
+  }
+
+  /**
+   * The name of the category list to put this category in, or {@code null} if
+   * this category should not be aggregatable.
+   * <p>
+   * By default, all categories are written to the same category list, but
+   * applications which know in advance that in some situations only parts of
+   * the category hierarchy needs to be counted can divide the categories into
+   * two or more different category lists.
    * <p>
-   * Note: Make sure <code>buffer</code> is large enough.
-   * @see CategoryPath#charsNeededForFullPath()
+   * If {@code null} is returned for a category, it means that this category
+   * should not appear in any category list, and thus weights for it cannot be
+   * aggregated. This category can still be used for drill-down, even though the
+   * its weight is unknown.
+   * 
+   * @see PerDimensionIndexingParams
    */
-  public int drillDownTermText(CategoryPath path, char[] buffer);
+  public CategoryListParams getCategoryListParams(CategoryPath category) {
+    return clParams;
+  }
 
   /**
-   * Get the partition size.
-   * Same value should be used during the life time of an index.
-   * At search time this value is compared with actual taxonomy size and their minimum is used.
+   * Copies the text required to execute a drill-down query on the given
+   * category to the given {@code char[]}, and returns the number of characters
+   * that were written.
+   * <p>
+   * <b>NOTE:</b> You should make sure that the {@code char[]} is large enough,
+   * by e.g. calling {@link CategoryPath#fullPathLength()}.
    */
-  public int getPartitionSize();
-
-  /** 
-   * Get the policy for indexing category <b>paths</b>, 
-   * used for deciding how "high" to climb in taxonomy 
-   * from a category when ingesting its category paths. 
+  public int drillDownTermText(CategoryPath path, char[] buffer) {
+    return path.copyFullPath(buffer, 0, getFacetDelimChar());
+  }
+  
+  /**
+   * Returns the size of a partition. <i>Partitions</i> allow you to divide
+   * (hence, partition) the categories space into small sets to e.g. improve RAM
+   * consumption during faceted search. For instance, {@code partitionSize=100K}
+   * would mean that if your taxonomy index contains 420K categories, they will
+   * be divided into 5 groups and at search time a {@link FacetArrays} will be
+   * allocated at the size of the partition.
+   * 
+   * <p>
+   * This is real advanced setting and should be changed with care. By default,
+   * all categories are put in one partition. You should modify this setting if
+   * you have really large taxonomies (e.g. 1M+ nodes).
+   */
+  public int getPartitionSize() {
+    return partitionSize;
+  }
+  
+  /**
+   * Returns a list of all {@link CategoryListParams categoryListParams} that
+   * are used for facets indexing.
    */
-  public PathPolicy getPathPolicy();
+  public List<CategoryListParams> getAllCategoryListParams() {
+    return Collections.singletonList(clParams);
+  }
 
-  /** 
-   * Get the policy for indexing category <b>ordinals</b>, 
-   * used for deciding how "high" to climb in taxonomy 
-   * from a category when ingesting its ordinals 
+  /**
+   * Returns the {@link OrdinalPolicy} that is used during indexing. By default
+   * returns {@link OrdinalPolicy#ALL_PARENTS} which means that the full
+   * hierarchy will be stored for every document.
+   */
+  public OrdinalPolicy getOrdinalPolicy() {
+    return ordinalPolicy;
+  }
+
+  /**
+   * Returns the {@link PathPolicy} that is used during indexing. By default
+   * returns {@link PathPolicy#ALL_CATEGORIES} which means that the full
+   * hierarchy is added as drill-down terms for every document.
+   */
+  public PathPolicy getPathPolicy() {
+    return pathPolicy;
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((clParams == null) ? 0 : clParams.hashCode());
+    result = prime * result + ((ordinalPolicy == null) ? 0 : ordinalPolicy.hashCode());
+    result = prime * result + partitionSize;
+    result = prime * result + ((pathPolicy == null) ? 0 : pathPolicy.hashCode());
+    
+    for (CategoryListParams clp : getAllCategoryListParams()) {
+      result ^= clp.hashCode();
+    }
+    
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
+      return true;
+    }
+    if (obj == null) {
+      return false;
+    }
+    if (!(obj instanceof FacetIndexingParams)) {
+      return false;
+    }
+    FacetIndexingParams other = (FacetIndexingParams) obj;
+    if (clParams == null) {
+      if (other.clParams != null) {
+        return false;
+      }
+    } else if (!clParams.equals(other.clParams)) {
+      return false;
+    }
+    if (ordinalPolicy == null) {
+      if (other.ordinalPolicy != null) {
+        return false;
+      }
+    } else if (!ordinalPolicy.equals(other.ordinalPolicy)) {
+      return false;
+    }
+    if (partitionSize != other.partitionSize) {
+      return false;
+    }
+    if (pathPolicy == null) {
+      if (other.pathPolicy != null) {
+        return false;
+      }
+    } else if (!pathPolicy.equals(other.pathPolicy)) {
+      return false;
+    }
+    
+    Iterable<CategoryListParams> cLs = getAllCategoryListParams();
+    Iterable<CategoryListParams> otherCLs = other.getAllCategoryListParams();
+    
+    return cLs.equals(otherCLs);
+  }
+
+  /**
+   * Returns the delimiter character used internally for concatenating category
+   * path components, e.g. for drill-down terms.
    */
-  public OrdinalPolicy getOrdinalPolicy();
-  
-  /** 
-   * Get the delimiter character used internally for drill-down terms 
-   */ 
-  public char getFacetDelimChar();
+  public char getFacetDelimChar() {
+    return DEFAULT_FACET_DELIM_CHAR;
+  }
+
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java Tue Jan  8 03:40:16 2013
@@ -2,7 +2,9 @@ package org.apache.lucene.facet.index.pa
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
@@ -24,79 +26,69 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * A FacetIndexingParams that utilizes different category lists, defined by the
- * dimension specified CategoryPaths (see
- * {@link PerDimensionIndexingParams#addCategoryListParams(CategoryPath, CategoryListParams)}
+ * A {@link FacetIndexingParams} that utilizes different category lists, defined
+ * by the dimension specified by a {@link CategoryPath category} (see
+ * {@link #PerDimensionIndexingParams(Map, CategoryListParams)}.
  * <p>
  * A 'dimension' is defined as the first or "zero-th" component in a
- * CategoryPath. For example, if a CategoryPath is defined as
- * "/Author/American/Mark Twain", then the dimension is "Author".
- * <p>
- * This class also uses the 'default' CategoryListParams (as specified by
- * {@link CategoryListParams#CategoryListParams()} when
- * {@link #getCategoryListParams(CategoryPath)} is called for a CategoryPath
- * whose dimension component has not been specifically defined.
+ * {@link CategoryPath}. For example, if a category is defined as
+ * "Author/American/Mark Twain", then the dimension would be "Author".
  * 
  * @lucene.experimental
  */
-public class PerDimensionIndexingParams extends DefaultFacetIndexingParams {
+public class PerDimensionIndexingParams extends FacetIndexingParams {
 
-  // "Root" or "first component" of a Category Path maps to a
-  // CategoryListParams
-  private final Map<String, CategoryListParams> clParamsMap = new HashMap<String, CategoryListParams>();
+  private final Map<String, CategoryListParams> clParamsMap;
 
   /**
-   * Construct with the default {@link CategoryListParams} as the default
-   * CategoryListParams for unspecified CategoryPaths.
+   * Initializes a new instance with the given dimension-to-params mapping. The
+   * dimension is considered as what's returned by
+   * {@link CategoryPath#components cp.components[0]}.
+   * 
+   * <p>
+   * <b>NOTE:</b> for any dimension whose {@link CategoryListParams} is not
+   * defined in the mapping, a default {@link CategoryListParams} will be used.
+   * 
+   * @see #PerDimensionIndexingParams(Map, CategoryListParams)
    */
-  public PerDimensionIndexingParams() {
-    this(new CategoryListParams());
+  public PerDimensionIndexingParams(Map<CategoryPath, CategoryListParams> paramsMap) {
+    this(paramsMap, DEFAULT_CATEGORY_LIST_PARAMS);
   }
 
   /**
-   * Construct with the included categoryListParams as the default
-   * CategoryListParams for unspecified CategoryPaths.
-   * 
-   * @param categoryListParams
-   *            the default categoryListParams to use
+   * Same as {@link #PerDimensionIndexingParams(Map)}, only the given
+   * {@link CategoryListParams} will be used for any dimension that is not
+   * specified in the given mapping.
    */
-  public PerDimensionIndexingParams(CategoryListParams categoryListParams) {
+  public PerDimensionIndexingParams(Map<CategoryPath, CategoryListParams> paramsMap, 
+      CategoryListParams categoryListParams) {
     super(categoryListParams);
+    clParamsMap = new HashMap<String,CategoryListParams>();
+    for (Entry<CategoryPath, CategoryListParams> e : paramsMap.entrySet()) {
+      clParamsMap.put(e.getKey().components[0], e.getValue());
+    }
   }
 
-  /**
-   * Get all the categoryListParams, including the default.
-   */
   @Override
-  public Iterable<CategoryListParams> getAllCategoryListParams() {
-    ArrayList<CategoryListParams> vals = 
-      new ArrayList<CategoryListParams>(clParamsMap.values());
-    for (CategoryListParams clp : super.getAllCategoryListParams()) {
-      vals.add(clp);
-    }
+  public List<CategoryListParams> getAllCategoryListParams() {
+    ArrayList<CategoryListParams> vals = new ArrayList<CategoryListParams>(clParamsMap.values());
+    vals.add(clParams); // add the default too
     return vals;
   }
 
   /**
-   * Get the CategoryListParams based on the dimension or "zero-th category"
-   * of the specified CategoryPath.
+   * Returns the {@link CategoryListParams} for the corresponding dimension
+   * which is returned by {@code category.getComponent(0)}.
    */
   @Override
   public CategoryListParams getCategoryListParams(CategoryPath category) {
     if (category != null) {
-      CategoryListParams clParams = clParamsMap.get(category.getComponent(0));
+      CategoryListParams clParams = clParamsMap.get(category.components[0]);
       if (clParams != null) {
         return clParams;
       }
     }
-    return super.getCategoryListParams(category);
+    return clParams;
   }
 
-  /**
-   * Add a CategoryListParams for a given CategoryPath's dimension or
-   * "zero-th" category.
-   */
-  public void addCategoryListParams(CategoryPath category, CategoryListParams clParams) {
-    clParamsMap.put(category.getComponent(0), clParams);
-  }
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java Tue Jan  8 03:40:16 2013
@@ -2,18 +2,15 @@ package org.apache.lucene.facet.search;
 
 import java.io.IOException;
 import java.util.List;
-import java.util.Random;
-
-import org.apache.lucene.index.IndexReader;
 
 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.sampling.RandomSampler;
-import org.apache.lucene.facet.search.sampling.RepeatableSampler;
 import org.apache.lucene.facet.search.sampling.Sampler;
 import org.apache.lucene.facet.search.sampling.SamplingAccumulator;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.index.IndexReader;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -59,14 +56,14 @@ public final class AdaptiveFacetsAccumul
   }
 
   /**
-   * Create an {@link AdaptiveFacetsAccumulator} 
-   * @see StandardFacetsAccumulator#StandardFacetsAccumulator(FacetSearchParams, IndexReader, TaxonomyReader, 
-   *                               IntArrayAllocator, FloatArrayAllocator)
+   * Create an {@link AdaptiveFacetsAccumulator}
+   * 
+   * @see StandardFacetsAccumulator#StandardFacetsAccumulator(FacetSearchParams,
+   *      IndexReader, TaxonomyReader, FacetArrays)
    */
   public AdaptiveFacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader,
-      TaxonomyReader taxonomyReader, IntArrayAllocator intArrayAllocator,
-      FloatArrayAllocator floatArrayAllocator) {
-    super(searchParams, indexReader, taxonomyReader, intArrayAllocator, floatArrayAllocator);
+      TaxonomyReader taxonomyReader, FacetArrays facetArrays) {
+    super(searchParams, indexReader, taxonomyReader, facetArrays);
   }
 
   /**

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/DrillDown.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/DrillDown.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/DrillDown.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/DrillDown.java Tue Jan  8 03:40:16 2013
@@ -53,7 +53,7 @@ public final class DrillDown {
   /** Return a drill-down {@link Term} for a category. */
   public static final Term term(FacetIndexingParams iParams, CategoryPath path) {
     CategoryListParams clp = iParams.getCategoryListParams(path);
-    char[] buffer = new char[path.charsNeededForFullPath()];
+    char[] buffer = new char[path.fullPathLength()];
     iParams.drillDownTermText(path, buffer);
     return new Term(clp.getTerm().field(), String.valueOf(buffer));
   }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetArrays.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetArrays.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetArrays.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetArrays.java Tue Jan  8 03:40:16 2013
@@ -18,74 +18,66 @@ package org.apache.lucene.facet.search;
  */
 
 /**
- * Provider of arrays used for facet operations such as counting.
+ * Provider of arrays used for facets aggregation. Returns either an
+ * {@code int[]} or {@code float[]} of the specified array length. When the
+ * arrays are no longer needed, you should call {@link #free()}, so that e.g.
+ * they will be reclaimed.
+ * 
+ * <p>
+ * <b>NOTE:</b> if you need to reuse the allocated arrays between search
+ * requests, use {@link ReusingFacetArrays}.
+ * 
+ * <p>
+ * <b>NOTE:</b> this class is not thread safe. You typically allocate it per
+ * search.
  * 
  * @lucene.experimental
  */
 public class FacetArrays {
 
-  private int[] intArray;
-  private float[] floatArray;
-  private IntArrayAllocator intArrayAllocator;
-  private FloatArrayAllocator floatArrayAllocator;
-  private int arraysLength;
-
-  /**
-   * Create a FacetArrays with certain array allocators.
-   * @param intArrayAllocator allocator for int arrays.
-   * @param floatArrayAllocator allocator for float arrays.
-   */
-  public FacetArrays(IntArrayAllocator intArrayAllocator,
-                      FloatArrayAllocator floatArrayAllocator) {
-    this.intArrayAllocator = intArrayAllocator;
-    this.floatArrayAllocator = floatArrayAllocator;
+  private int[] ints;
+  private float[] floats;
+  
+  public final int arrayLength;
+
+  /** Arrays will be allocated at the specified length. */
+  public FacetArrays(int arrayLength) {
+    this.arrayLength = arrayLength;
   }
-
-  /**
-   * Notify allocators that they can free arrays allocated 
-   * on behalf of this FacetArrays object. 
-   */
-  public void free() {
-    if (intArrayAllocator!=null) {
-      intArrayAllocator.free(intArray);
-      // Should give up handle to the array now
-      // that it is freed.
-      intArray = null;
-    }
-    if (floatArrayAllocator!=null) {
-      floatArrayAllocator.free(floatArray);
-      // Should give up handle to the array now
-      // that it is freed.
-      floatArray = null;
-    }
-    arraysLength = 0;
+  
+  protected float[] newFloatArray() {
+    return new float[arrayLength];
   }
-
+  
+  protected int[] newIntArray() {
+    return new int[arrayLength];
+  }
+  
+  protected void doFree(float[] floats, int[] ints) {
+  }
+  
   /**
-   * Obtain an int array, e.g. for facet counting. 
+   * Notifies that the arrays obtained from {@link #getIntArray()}
+   * or {@link #getFloatArray()} are no longer needed and can be freed.
    */
-  public int[] getIntArray() {
-    if (intArray == null) {
-      intArray = intArrayAllocator.allocate();
-      arraysLength = intArray.length;
-    }
-    return intArray;
+  public final void free() {
+    doFree(floats, ints);
+    ints = null;
+    floats = null;
   }
 
-  /** Obtain a float array, e.g. for evaluating facet association values. */
-  public float[] getFloatArray() {
-    if (floatArray == null) {
-      floatArray = floatArrayAllocator.allocate();
-      arraysLength = floatArray.length;
+  public final int[] getIntArray() {
+    if (ints == null) {
+      ints = newIntArray();
     }
-    return floatArray;
+    return ints;
   }
 
-  /**
-   * Return the arrays length
-   */
-  public int getArraysLength() {
-    return arraysLength;
+  public final float[] getFloatArray() {
+    if (floats == null) {
+      floats = newFloatArray();
+    }
+    return floats;
   }
 
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java Tue Jan  8 03:40:16 2013
@@ -154,7 +154,7 @@ public abstract class FacetResultsHandle
    *          offset in input arrays where partition starts
    */
   protected boolean isSelfPartition (int ordinal, FacetArrays facetArrays, int offset) {
-    int partitionSize = facetArrays.getArraysLength();
+    int partitionSize = facetArrays.arrayLength;
     return ordinal / partitionSize == offset / partitionSize;
   }
 

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/ScoredDocIdCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/ScoredDocIdCollector.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/ScoredDocIdCollector.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/ScoredDocIdCollector.java Tue Jan  8 03:40:16 2013
@@ -68,9 +68,12 @@ public abstract class ScoredDocIdCollect
         private DocIdSetIterator docIdsIter = docIds.iterator();
         private int nextDoc;
 
+        @Override
         public int getDocID() { return nextDoc; }
+        @Override
         public float getScore() { return defaultScore; }
 
+        @Override
         public boolean next() {
           try {
             nextDoc = docIdsIter.nextDoc();
@@ -133,9 +136,12 @@ public abstract class ScoredDocIdCollect
         private int nextDoc;
         private int scoresIdx = -1;
 
+        @Override
         public int getDocID() { return nextDoc; }
+        @Override
         public float getScore() { return scores[scoresIdx]; }
 
+        @Override
         public boolean next() {
           try {
             nextDoc = docIdsIter.nextDoc();
@@ -203,14 +209,17 @@ public abstract class ScoredDocIdCollect
   public ScoredDocIDs getScoredDocIDs() {
     return new ScoredDocIDs() {
 
+      @Override
       public ScoredDocIDsIterator iterator() throws IOException {
         return scoredDocIdsIterator();
       }
 
+      @Override
       public DocIdSet getDocIDs() {
         return docIds;
       }
 
+      @Override
       public int size() {
         return numDocIds;
       }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java Tue Jan  8 03:40:16 2013
@@ -3,6 +3,7 @@ package org.apache.lucene.facet.search;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.logging.Level;
@@ -62,8 +63,7 @@ public class StandardFacetsAccumulator e
 
   private static final Logger logger = Logger.getLogger(StandardFacetsAccumulator.class.getName());
 
-  protected final IntArrayAllocator intArrayAllocator;
-  protected final FloatArrayAllocator floatArrayAllocator;
+  protected final FacetArrays facetArrays;
 
   protected int partitionSize;
   protected int maxPartitions;
@@ -74,31 +74,25 @@ public class StandardFacetsAccumulator e
   private Object accumulateGuard;
 
   public StandardFacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader,
-      TaxonomyReader taxonomyReader, IntArrayAllocator intArrayAllocator,
-      FloatArrayAllocator floatArrayAllocator) {
-    
+      TaxonomyReader taxonomyReader, FacetArrays facetArrays) {
     super(searchParams,indexReader,taxonomyReader);
-    int realPartitionSize = intArrayAllocator == null || floatArrayAllocator == null 
-              ? PartitionsUtils.partitionSize(searchParams, taxonomyReader) : -1; // -1 if not needed.
-    this.intArrayAllocator = intArrayAllocator != null 
-        ? intArrayAllocator
-        // create a default one if null was provided
-        : new IntArrayAllocator(realPartitionSize, 1);
-    this.floatArrayAllocator = floatArrayAllocator != null 
-        ? floatArrayAllocator
-        // create a default one if null provided
-        : new FloatArrayAllocator(realPartitionSize, 1);
+    
+    if (facetArrays == null) {
+      throw new IllegalArgumentException("facetArrays cannot be null");
+    }
+    
+    this.facetArrays = facetArrays;
     // can only be computed later when docids size is known
     isUsingComplements = false;
-    partitionSize = PartitionsUtils.partitionSize(searchParams, taxonomyReader);
+    partitionSize = PartitionsUtils.partitionSize(searchParams.getFacetIndexingParams(), taxonomyReader);
     maxPartitions = (int) Math.ceil(this.taxonomyReader.getSize() / (double) partitionSize);
     accumulateGuard = new Object();
   }
 
-  public StandardFacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader,
-      TaxonomyReader taxonomyReader) {
-    
-    this(searchParams, indexReader, taxonomyReader, null, null);
+  public StandardFacetsAccumulator(FacetSearchParams searchParams,
+      IndexReader indexReader, TaxonomyReader taxonomyReader) {
+    this(searchParams, indexReader, taxonomyReader, new FacetArrays(
+        PartitionsUtils.partitionSize(searchParams.getFacetIndexingParams(), taxonomyReader)));
   }
 
   @Override
@@ -116,7 +110,7 @@ public class StandardFacetsAccumulator e
         try {
           totalFacetCounts = TotalFacetCountsCache.getSingleton()
             .getTotalCounts(indexReader, taxonomyReader,
-                searchParams.getFacetIndexingParams(), searchParams.getClCache());
+                searchParams.getFacetIndexingParams(), searchParams.getCategoryListCache());
           if (totalFacetCounts != null) {
             docids = ScoredDocIdsUtils.getComplementSet(docids, indexReader);
           } else {
@@ -142,18 +136,12 @@ public class StandardFacetsAccumulator e
           isUsingComplements = false;
         } catch (Exception e) {
           // give up: this should not happen!
-          IOException ioEx = new IOException(
-              "PANIC: Got unexpected exception while trying to get/calculate total counts: "
-              +e.getMessage());
-          ioEx.initCause(e);
-          throw ioEx;
+          throw new IOException("PANIC: Got unexpected exception while trying to get/calculate total counts", e);
         }
       }
 
       docids = actualDocsToAccumulate(docids);
 
-      FacetArrays facetArrays = new FacetArrays(intArrayAllocator, floatArrayAllocator);
-
       HashMap<FacetRequest, IntermediateFacetResult> fr2tmpRes = new HashMap<FacetRequest, IntermediateFacetResult>();
 
       try {
@@ -165,19 +153,21 @@ public class StandardFacetsAccumulator e
           int offset = part * partitionSize;
 
           // for each partition we go over all requests and handle
-          // each, where
-          // the request maintains the merged result.
-          // In this implementation merges happen after each
-          // partition,
+          // each, where the request maintains the merged result.
+          // In this implementation merges happen after each partition,
           // but other impl could merge only at the end.
+          final HashSet<FacetRequest> handledRequests = new HashSet<FacetRequest>();
           for (FacetRequest fr : searchParams.getFacetRequests()) {
-            FacetResultsHandler frHndlr = fr.createFacetResultsHandler(taxonomyReader);
-            IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(facetArrays, offset);
-            IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
-            if (oldRes != null) {
-              res4fr = frHndlr.mergeResults(oldRes, res4fr);
-            }
-            fr2tmpRes.put(fr, res4fr);
+            // Handle and merge only facet requests which were not already handled.  
+            if (handledRequests.add(fr)) {
+              FacetResultsHandler frHndlr = fr.createFacetResultsHandler(taxonomyReader);
+              IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(facetArrays, offset);
+              IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
+              if (oldRes != null) {
+                res4fr = frHndlr.mergeResults(oldRes, res4fr);
+              }
+              fr2tmpRes.put(fr, res4fr);
+            } 
           }
         }
       } finally {
@@ -273,7 +263,7 @@ public class StandardFacetsAccumulator e
     int[] intArray = facetArrays.getIntArray();
     totalFacetCounts.fillTotalCountsForPartition(intArray, partition);
     double totalCountsFactor = getTotalCountsFactor();
-    // fix total counts, but only if the effect of this would be meaningfull. 
+    // fix total counts, but only if the effect of this would be meaningful. 
     if (totalCountsFactor < 0.99999) {
       int delta = nAccumulatedDocs + 1;
       for (int i = 0; i < intArray.length; i++) {

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java Tue Jan  8 03:40:16 2013
@@ -59,7 +59,7 @@ public class TopKFacetResultsHandler ext
     if (ordinal != TaxonomyReader.INVALID_ORDINAL) {
       double value = 0;  
       if (isSelfPartition(ordinal, facetArrays, offset)) {
-        int partitionSize = facetArrays.getArraysLength();
+        int partitionSize = facetArrays.arrayLength;
         value = facetRequest.getValueOf(facetArrays, ordinal % partitionSize);
       }
       
@@ -121,7 +121,7 @@ public class TopKFacetResultsHandler ext
    */
   private int heapDescendants(int ordinal, Heap<FacetResultNode> pq,
       MutableFacetResultNode parentResultNode, FacetArrays facetArrays, int offset) throws IOException {
-    int partitionSize = facetArrays.getArraysLength();
+    int partitionSize = facetArrays.arrayLength;
     int endOffset = offset + partitionSize;
     ParallelTaxonomyArrays childrenArray = taxonomyReader.getParallelTaxonomyArrays();
     int[] children = childrenArray.children();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java Tue Jan  8 03:40:16 2013
@@ -119,7 +119,7 @@ public class TopKInEachNodeHandler exten
     // this will grow into the returned IntermediateFacetResult
     IntToObjectMap<AACO> AACOsOfOnePartition = new IntToObjectMap<AACO>();
 
-    int partitionSize = arrays.getArraysLength(); // all partitions, except, possibly, the last,
+    int partitionSize = arrays.arrayLength; // all partitions, except, possibly, the last,
     // have the same length. Hence modulo is OK.
 
     int depth = facetRequest.getDepth();

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java Tue Jan  8 03:40:16 2013
@@ -8,21 +8,25 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.lucene.index.IndexReader;
-
 import org.apache.lucene.facet.index.params.CategoryListParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.aggregator.Aggregator;
 import org.apache.lucene.facet.search.aggregator.CountingAggregator;
 import org.apache.lucene.facet.search.cache.CategoryListCache;
 import org.apache.lucene.facet.search.cache.CategoryListData;
+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.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.util.PartitionsUtils;
 import org.apache.lucene.facet.util.ScoredDocIdsUtils;
+import org.apache.lucene.index.IndexReader;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -146,13 +150,17 @@ public class TotalFacetCounts {
       dos.close();
     }
   }
+  
+  // needed because FacetSearchParams do not allow empty FacetRequests
+  private static final List<FacetRequest> DUMMY_REQ = Arrays.asList(
+      new FacetRequest[] { new CountFacetRequest(CategoryPath.EMPTY, 1) });
 
   static TotalFacetCounts compute(final IndexReader indexReader,
       final TaxonomyReader taxonomy, final FacetIndexingParams facetIndexingParams,
       final CategoryListCache clCache) throws IOException {
     int partitionSize = PartitionsUtils.partitionSize(facetIndexingParams, taxonomy);
     final int[][] counts = new int[(int) Math.ceil(taxonomy.getSize()  /(float) partitionSize)][partitionSize];
-    FacetSearchParams newSearchParams = new FacetSearchParams(facetIndexingParams); 
+    FacetSearchParams newSearchParams = new FacetSearchParams(DUMMY_REQ, facetIndexingParams); 
       //createAllListsSearchParams(facetIndexingParams,  this.totalCounts);
     FacetsAccumulator fe = new StandardFacetsAccumulator(newSearchParams, indexReader, taxonomy) {
       @Override

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/CountingAggregator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/CountingAggregator.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/CountingAggregator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/CountingAggregator.java Tue Jan  8 03:40:16 2013
@@ -28,10 +28,12 @@ public class CountingAggregator implemen
 
   protected int[] counterArray;
 
+  @Override
   public void aggregate(int ordinal) {
     ++counterArray[ordinal];
   }
 
+  @Override
   public void setNextDoc(int docid, float score) {
     // There's nothing for us to do here since we only increment the count by 1
     // in this aggregator.

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/ScoringAggregator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/ScoringAggregator.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/ScoringAggregator.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/aggregator/ScoringAggregator.java Tue Jan  8 03:40:16 2013
@@ -34,6 +34,7 @@ public class ScoringAggregator implement
     this.hashCode = scoreArray == null ? 0 : scoreArray.hashCode();
   }
 
+  @Override
   public void aggregate(int ordinal) {
     scoreArray[ordinal] += score;
   }
@@ -52,6 +53,7 @@ public class ScoringAggregator implement
     return hashCode;
   }
 
+  @Override
   public void setNextDoc(int docid, float score) {
     this.score = score;
   }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/cache/CategoryListData.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/cache/CategoryListData.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/cache/CategoryListData.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/cache/CategoryListData.java Tue Jan  8 03:40:16 2013
@@ -112,10 +112,12 @@ public class CategoryListData {
       dpc = docPartitionCategories;
     }
 
+    @Override
     public boolean init() throws IOException {
       return dpc!=null && dpc.length>part;
     }
 
+    @Override
     public long nextCategory() throws IOException {
       if (nextCategoryIndex >= dpc[currDoc][part].length) {
         return 1L+Integer.MAX_VALUE;
@@ -123,6 +125,7 @@ public class CategoryListData {
       return dpc[currDoc][part][nextCategoryIndex++]; 
     }
 
+    @Override
     public boolean skipTo(int docId) throws IOException {
       final boolean res = dpc.length>docId && dpc[docId]!=null && dpc[docId][part]!=null;
       if (res) {

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java Tue Jan  8 03:40:16 2013
@@ -332,7 +332,7 @@ public abstract class FacetRequest imple
   public CategoryListIterator createCategoryListIterator(IndexReader reader,
       TaxonomyReader taxo, FacetSearchParams sParams, int partition)
       throws IOException {
-    CategoryListCache clCache = sParams.getClCache();
+    CategoryListCache clCache = sParams.getCategoryListCache();
     CategoryListParams clParams = sParams.getFacetIndexingParams().getCategoryListParams(categoryPath);
     if (clCache!=null) {
       CategoryListData clData = clCache.get(clParams);

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java Tue Jan  8 03:40:16 2013
@@ -1,12 +1,10 @@
 package org.apache.lucene.facet.search.params;
 
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.cache.CategoryListCache;
-import org.apache.lucene.facet.search.results.FacetResult;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,12 +24,13 @@ import org.apache.lucene.facet.search.re
  */
 
 /**
- * Faceted search parameters indicate for which facets should info be gathered.
+ * Defines parameters that are needed for faceted search. The list of
+ * {@link FacetRequest facet requests} denotes the facets for which aggregated
+ * should be done.
  * <p>
- * The contained facet requests define for which facets should info be gathered.
- * <p>
- * Contained faceted indexing parameters provide required info on how
- * to read and interpret the underlying faceted information in the search index.   
+ * One can pass {@link FacetIndexingParams} in order to tell the search code how
+ * to read the facets information. Note that you must use the same
+ * {@link FacetIndexingParams} that were used for indexing.
  * 
  * @lucene.experimental
  */
@@ -39,64 +38,63 @@ public class FacetSearchParams {
 
   protected final FacetIndexingParams indexingParams;
   protected final List<FacetRequest> facetRequests;
-  private CategoryListCache clCache = null;
+  
+  /**
+   * Initializes with the given {@link FacetRequest requests} and default
+   * {@link FacetIndexingParams#ALL_PARENTS}. If you used a different
+   * {@link FacetIndexingParams}, you should use
+   * {@link #FacetSearchParams(List, FacetIndexingParams)}.
+   */
+  public FacetSearchParams(FacetRequest... facetRequests) {
+    this(Arrays.asList(facetRequests), FacetIndexingParams.ALL_PARENTS);
+  }
+  
+  /**
+   * Initializes with the given {@link FacetRequest requests} and default
+   * {@link FacetIndexingParams#ALL_PARENTS}. If you used a different
+   * {@link FacetIndexingParams}, you should use
+   * {@link #FacetSearchParams(List, FacetIndexingParams)}.
+   */
+  public FacetSearchParams(List<FacetRequest> facetRequests) {
+    this(facetRequests, FacetIndexingParams.ALL_PARENTS);
+  }
 
   /**
-   * Construct with specific faceted indexing parameters.
-   * It is important to know the indexing parameters so as to e.g. 
-   * read facets data correctly from the index.
-   * {@link #addFacetRequest(FacetRequest)} must be called at least once 
-   * for this faceted search to find any faceted result.
-   * @param indexingParams Indexing faceted parameters which were used at indexing time.
-   * @see #addFacetRequest(FacetRequest)
+   * Initilizes with the given {@link FacetRequest requests} and
+   * {@link FacetIndexingParams}.
    */
-  public FacetSearchParams(FacetIndexingParams indexingParams) {
+  public FacetSearchParams(List<FacetRequest> facetRequests, FacetIndexingParams indexingParams) {
+    if (facetRequests == null || facetRequests.size() == 0) {
+      throw new IllegalArgumentException("at least one FacetRequest must be defined");
+    }
     this.indexingParams = indexingParams;
-    facetRequests = new ArrayList<FacetRequest>();
+    this.facetRequests = facetRequests;
   }
 
   /**
-   * Construct with default faceted indexing parameters.
-   * Usage of this constructor is valid only if also during indexing the 
-   * default faceted indexing parameters were used.   
-   * {@link #addFacetRequest(FacetRequest)} must be called at least once 
-   * for this faceted search to find any faceted result.
-   * @see #addFacetRequest(FacetRequest)
+   * Returns the {@link CategoryListCache}. By default returns {@code null}, you
+   * should override if you want to use a cache.
    */
-  public FacetSearchParams() {
-    this(new DefaultFacetIndexingParams());
+  public CategoryListCache getCategoryListCache() {
+    return null;
   }
 
   /**
-   * A list of {@link FacetRequest} objects, determining what to count.
-   * If the returned collection is empty, the faceted search will return no facet results!
+   * Returns the {@link FacetIndexingParams} that were passed to the
+   * constructor.
    */
-  public final FacetIndexingParams getFacetIndexingParams() {
+  public FacetIndexingParams getFacetIndexingParams() {
     return indexingParams;
   }
-
+  
   /**
-   * Parameters which controlled the indexing of facets, and which are also
-   * needed during search.
+   * Returns the list of {@link FacetRequest facet requests} that were passed to
+   * the constructor.
    */
-  public final List<FacetRequest> getFacetRequests() {
+  public List<FacetRequest> getFacetRequests() {
     return facetRequests;
   }
 
-  /**
-   * Add a facet request to apply for this faceted search.
-   * This method must be called at least once for faceted search 
-   * to find any faceted result. <br>
-   * NOTE: The order of addition implies the order of the {@link FacetResult}s
-   * @param facetRequest facet request to be added.
-   */
-  public void addFacetRequest(FacetRequest facetRequest) {
-    if (facetRequest == null) {
-      throw new IllegalArgumentException("Provided facetRequest must not be null");
-    }
-    facetRequests.add(facetRequest);
-  }
-  
   @Override
   public String toString() {
     final char TAB = '\t';
@@ -112,19 +110,4 @@ public class FacetSearchParams {
     
     return sb.toString();
   }
-
-  /**
-   * @return the cldCache in effect
-   */
-  public CategoryListCache getClCache() {
-    return clCache;
-  }
-
-  /**
-   * Set Cached Category Lists data to be used in Faceted search.
-   * @param clCache the cldCache to set
-   */
-  public void setClCache(CategoryListCache clCache) {
-    this.clCache = clCache;
-  }
 }

Modified: lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/results/MutableFacetResultNode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/results/MutableFacetResultNode.java?rev=1430130&r1=1430129&r2=1430130&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/results/MutableFacetResultNode.java (original)
+++ lucene/dev/branches/lucene4547/lucene/facet/src/java/org/apache/lucene/facet/search/results/MutableFacetResultNode.java Tue Jan  8 03:40:16 2013
@@ -145,6 +145,7 @@ public class MutableFacetResultNode impl
    * org.apache.lucene.facet.search.results2.FacetResultNode#toString(java.lang.
    * String)
    */
+  @Override
   public String toString(String prefix) {
     StringBuilder sb = new StringBuilder(prefix);
     
@@ -171,10 +172,12 @@ public class MutableFacetResultNode impl
     return sb.toString();
   }
   
+  @Override
   public final int getOrdinal() {
     return ordinal;
   }
   
+  @Override
   public final CategoryPath getLabel() {
     return label;
   }
@@ -188,6 +191,7 @@ public class MutableFacetResultNode impl
     this.label = label;
   }
   
+  @Override
   public final double getValue() {
     return value;
   }
@@ -199,6 +203,7 @@ public class MutableFacetResultNode impl
    *          the value to set
    * @see #getValue()
    */
+  @Override
   public void setValue(double value) {
     this.value = value;
   }
@@ -212,6 +217,7 @@ public class MutableFacetResultNode impl
     this.value += addedValue;
   }
   
+  @Override
   public final double getResidue() {
     return residue;
   }
@@ -234,6 +240,7 @@ public class MutableFacetResultNode impl
     this.residue += addedResidue;
   }
   
+  @Override
   public final Iterable<? extends FacetResultNode> getSubResults() {
     return subResults != null ? subResults : EMPTY_SUB_RESULTS;
   }
@@ -308,6 +315,7 @@ public class MutableFacetResultNode impl
    * org.apache.lucene.facet.search.results.FacetResultNode#getLabel(org.apache.lucene
    * .facet.taxonomy.TaxonomyReader)
    */
+  @Override
   public final CategoryPath getLabel(TaxonomyReader taxonomyReader)
       throws IOException {
     if (label == null) {
@@ -321,6 +329,7 @@ public class MutableFacetResultNode impl
    * 
    * @see org.apache.lucene.facet.search.results.FacetResultNode#getNumSubResults()
    */
+  @Override
   public final int getNumSubResults() {
     return subResults == null ? 0 : subResults.size();
   }

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=1430130&r1=1430129&r2=1430130&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 Tue Jan  8 03:40:16 2013
@@ -1,6 +1,8 @@
 package org.apache.lucene.facet.search.sampling;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.lucene.index.IndexReader;
 
@@ -183,11 +185,12 @@ public abstract class Sampler {
     // So now we can sample -> altering the searchParams to accommodate for the statistical error for the sampling
     double overSampleFactor = getSamplingParams().getOversampleFactor();
     if (overSampleFactor > 1) { // any factoring to do?
-      res = new FacetSearchParams(original.getFacetIndexingParams());
-      for (FacetRequest frq: original.getFacetRequests()) {
+      List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+      for (FacetRequest frq : original.getFacetRequests()) {
         int overSampledNumResults = (int) Math.ceil(frq.getNumResults() * overSampleFactor);
-        res.addFacetRequest(new OverSampledFacetRequest(frq, overSampledNumResults));
+        facetRequests.add(new OverSampledFacetRequest(frq, overSampledNumResults));
       }
+      res = new FacetSearchParams(facetRequests, original.getFacetIndexingParams());
     }
     return res;
   }