Examples of OldFacetsAccumulator


Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

      final FacetIndexingParams facetIndexingParams) 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, DUMMY_REQ);
      //createAllListsSearchParams(facetIndexingParams,  this.totalCounts);
    OldFacetsAccumulator sfa = new OldFacetsAccumulator(newSearchParams, indexReader, taxonomy) {
      @Override
      protected HashMap<CategoryListIterator, Aggregator> getCategoryListMap(
          FacetArrays facetArrays, int partition) throws IOException {
       
        Aggregator aggregator = new CountingAggregator(counts[partition]);
        HashMap<CategoryListIterator, Aggregator> map = new HashMap<CategoryListIterator, Aggregator>();
        for (CategoryListParams clp: facetIndexingParams.getAllCategoryListParams()) {
          map.put(clp.createCategoryListIterator(partition), aggregator);
        }
        return map;
      }
    };
    sfa.setComplementThreshold(OldFacetsAccumulator.DISABLE_COMPLEMENT);
    sfa.accumulate(ScoredDocIdsUtils.createAllDocsScoredDocIDs(indexReader));
    return new TotalFacetCounts(taxonomy, facetIndexingParams, counts, CreationType.Computed);
  }
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

public class SamplingWrapperTest extends BaseSampleTestTopK {

  @Override
  protected OldFacetsAccumulator getSamplingAccumulator(Sampler sampler, TaxonomyReader taxoReader,
      IndexReader indexReader, FacetSearchParams searchParams) {
    return new SamplingWrapper(new OldFacetsAccumulator(searchParams, indexReader, taxoReader), sampler);
  }
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

  /** search reader <code>r</code>*/
  private FacetResult searchWithFacets(IndexReader r, TaxonomyReader tr, FacetSearchParams fsp,
      final SamplingParams params) throws IOException {
    // a FacetsCollector with a sampling accumulator
    Sampler sampler = new RandomSampler(params, random());
    OldFacetsAccumulator sfa = new SamplingAccumulator(sampler, fsp, r, tr);
    FacetsCollector fcWithSampling = FacetsCollector.create(sfa);
   
    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fcWithSampling);
   
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

    assertSameResults(expected, sampledResults);
  }
 
  private FacetsCollector samplingCollector(final boolean complement, final Sampler sampler,
      FacetSearchParams samplingSearchParams) {
    OldFacetsAccumulator sfa = getSamplingAccumulator(sampler, taxoReader, indexReader, samplingSearchParams);
    sfa.setComplementThreshold(complement ? OldFacetsAccumulator.FORCE_COMPLEMENT : OldFacetsAccumulator.DISABLE_COMPLEMENT);
    return FacetsCollector.create(sfa);
  }
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

  }
 
  /** compute facets with certain facet requests and docs */
  private List<FacetResult> findFacets(boolean withComplement) throws IOException {
    FacetSearchParams fsp = new FacetSearchParams(fip, new CountFacetRequest(new CategoryPath("root","a"), 10));
    OldFacetsAccumulator sfa = new OldFacetsAccumulator(fsp, indexReader, taxoReader);
    sfa.setComplementThreshold(withComplement ? OldFacetsAccumulator.FORCE_COMPLEMENT : OldFacetsAccumulator.DISABLE_COMPLEMENT);
    FacetsCollector fc = FacetsCollector.create(sfa);
    searcher.search(new MatchAllDocsQuery(), fc);
   
    List<FacetResult> res = fc.getFacetResults();
   
    // Results are ready, printing them...
    int i = 0;
    if (VERBOSE) {
      for (FacetResult facetResult : res) {
        System.out.println("Res "+(i++)+": "+facetResult);
      }
    }
   
    assertEquals(withComplement, sfa.isUsingComplements());
   
    return res;
  }
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

   *          the categories weights in. Can be {@code null}.
   */
  public static FacetsAccumulator create(FacetSearchParams fsp, IndexReader indexReader, TaxonomyReader taxoReader,
      FacetArrays arrays) {
    if (fsp.indexingParams.getPartitionSize() != Integer.MAX_VALUE) {
      return new OldFacetsAccumulator(fsp, indexReader, taxoReader, arrays);
    }
   
    List<FacetRequest> rangeRequests = new ArrayList<FacetRequest>();
    List<FacetRequest> nonRangeRequests = new ArrayList<FacetRequest>();
    for (FacetRequest fr : fsp.facetRequests) {
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

 
  private List<FacetResult> countFacets(FacetIndexingParams fip, int numResults, final boolean doComplement)
      throws IOException {
    Query q = new MatchAllDocsQuery();
    FacetSearchParams facetSearchParams = searchParamsWithRequests(numResults, fip);
    OldFacetsAccumulator sfa = new OldFacetsAccumulator(facetSearchParams, indexReader, taxoReader);
    sfa.setComplementThreshold(doComplement ? OldFacetsAccumulator.FORCE_COMPLEMENT : OldFacetsAccumulator.DISABLE_COMPLEMENT);
    FacetsCollector fc = FacetsCollector.create(sfa);
    searcher.search(q, fc);
    List<FacetResult> facetResults = fc.getFacetResults();
    return facetResults;
  }
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

      facetRequests.add(doctor);
      facetRequests.add(cfrb20);
      FacetSearchParams facetSearchParams = new FacetSearchParams(iParams, facetRequests);
     
      FacetArrays facetArrays = new FacetArrays(PartitionsUtils.partitionSize(facetSearchParams.indexingParams, tr));
      OldFacetsAccumulator sfa = new OldFacetsAccumulator(facetSearchParams, is.getIndexReader(), tr, facetArrays);
      sfa.setComplementThreshold(OldFacetsAccumulator.DISABLE_COMPLEMENT);
      FacetsCollector fc = FacetsCollector.create(sfa);
     
      is.search(q, fc);
      List<FacetResult> facetResults = fc.getFacetResults();

      FacetResult fr = facetResults.get(0); // a, depth=3, K=2
      boolean hasDoctor = "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
      assertEquals(9, fr.getNumValidDescendants());
      FacetResultNode parentRes = fr.getFacetResultNode();
      assertEquals(2, parentRes.subResults.size());
      // two nodes sorted by descending values: a/b with 8  and a/c with 6
      // a/b has two children a/b/2 with value 3, and a/b/1 with value 2.
      // a/c has one child a/c/1 with value 1.
      double [] expectedValues0 = { 8.0, 3.0, 2.0, 6.0, 1.0 };
      int i = 0;
      for (FacetResultNode node : parentRes.subResults) {
        assertEquals(expectedValues0[i++], node.value, Double.MIN_VALUE);
        for (FacetResultNode node2 : node.subResults) {
          assertEquals(expectedValues0[i++], node2.value, 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 one child a/c/1 with value 1
      // then a/b with value 5, and both children: a/b/2 with value 3, and a/b/1 with value 2.
      for (FacetResultNode node : parentRes.subResults) {
        node.value = 5.0;
        break;
      }
      // now rearrange
      double [] expectedValues00 = { 6.0, 1.0, 5.0, 3.0, 2.0 };
      fr = sfa.createFacetResultsHandler(cfra23, sfa.createOrdinalValueResolver(cfra23)).rearrangeFacetResult(fr);
      i = 0;
      for (FacetResultNode node : parentRes.subResults) {
        assertEquals(expectedValues00[i++], node.value, Double.MIN_VALUE);
        for (FacetResultNode node2 : node.subResults) {
          assertEquals(expectedValues00[i++], node2.value, Double.MIN_VALUE);
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

    DirectoryReader r = DirectoryReader.open(indexDir);
    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(CategoryPath.EMPTY, 10));
   
    final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
    FacetsCollector fc = FacetsCollector.create(fa);
    newSearcher(r).search(new MatchAllDocsQuery(), fc);
   
    FacetResult res = fc.getFacetResults().get(0);
    for (FacetResultNode node : res.getFacetResultNode().subResults) {
View Full Code Here

Examples of org.apache.lucene.facet.old.OldFacetsAccumulator

    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
   
    FacetSearchParams fsp = new FacetSearchParams(
        new CountFacetRequest(new CategoryPath("a"), 10),
        new CountFacetRequest(new CategoryPath("b"), 10));
    final TaxonomyFacetsAccumulator fa = random().nextBoolean() ? new TaxonomyFacetsAccumulator(fsp, r, taxo) : new OldFacetsAccumulator(fsp, r, taxo);
    final FacetsCollector fc = FacetsCollector.create(fa);
    newSearcher(r).search(new MatchAllDocsQuery(), fc);
   
    List<FacetResult> res1 = fc.getFacetResults();
    List<FacetResult> res2 = fc.getFacetResults();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.