Package org.apache.lucene.facet.partitions

Examples of org.apache.lucene.facet.partitions.PartitionsFacetResultsHandler


          // but other impl could merge only at the end.
          final HashSet<FacetRequest> handledRequests = new HashSet<FacetRequest>();
          for (FacetRequest fr : searchParams.facetRequests) {
            // Handle and merge only facet requests which were not already handled. 
            if (handledRequests.add(fr)) {
              PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr, createOrdinalValueResolver(fr));
              IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(offset);
              IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
              if (oldRes != null) {
                res4fr = frHndlr.mergeResults(oldRes, res4fr);
              }
              fr2tmpRes.put(fr, res4fr);
            }
          }
        }
      } finally {
        facetArrays.free();
      }

      // gather results from all requests into a list for returning them
      List<FacetResult> res = new ArrayList<FacetResult>();
      for (FacetRequest fr : searchParams.facetRequests) {
        PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr, createOrdinalValueResolver(fr));
        IntermediateFacetResult tmpResult = fr2tmpRes.get(fr);
        if (tmpResult == null) {
          // Add empty FacetResult:
          res.add(emptyResult(taxonomyReader.getOrdinal(fr.categoryPath), fr));
          continue;
        }
        FacetResult facetRes = frHndlr.renderFacetResult(tmpResult);
        // final labeling if allowed (because labeling is a costly operation)
        frHndlr.labelResult(facetRes);
        res.add(facetRes);
      }

      return res;
    }
View Full Code Here


    SampleFixer sampleFixer = sampler.samplingParams.getSampleFixer();
   
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      FacetRequest fr = fres.getFacetRequest();
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fr, createOrdinalValueResolver(fr));
      if (sampleFixer != null) {
        // fix the result of current request
        sampleFixer.fixResult(docids, fres, sampleSet.actualSampleRatio);
        fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any
      }
     
      if (shouldOversample) {
        // Using the sampler to trim the extra (over-sampled) results
        fres = sampler.trimResult(fres);
      }
     
      // final labeling if allowed (because labeling is a costly operation)
      if (fres.getFacetResultNode().ordinal == TaxonomyReader.INVALID_ORDINAL) {
        // category does not exist, add an empty result
        results.add(emptyResult(fres.getFacetResultNode().ordinal, fr));
      } else {
        frh.labelResult(fres);
        results.add(fres);
      }
    }

    if (shouldOversample) {
View Full Code Here

   
    List<FacetResult> results = new ArrayList<FacetResult>();
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      FacetRequest fr = fres.getFacetRequest();
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fr, createOrdinalValueResolver(fr));
      if (samplerFixer != null) {
        // fix the result of current request
        samplerFixer.fixResult(docids, fres, samplingRatio);
       
        fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any arranging it needs to

        if (shouldOversample) {
          // Using the sampler to trim the extra (over-sampled) results
          fres = sampler.trimResult(fres);
        }
      }
     
      // final labeling if allowed (because labeling is a costly operation)
      if (fres.getFacetResultNode().ordinal == TaxonomyReader.INVALID_ORDINAL) {
        // category does not exist, add an empty result
        results.add(emptyResult(fres.getFacetResultNode().ordinal, fr));
      } else {
        frh.labelResult(fres);
        results.add(fres);
      }
    }
   
    searchParams = original; // Back to original params
View Full Code Here

          // but other impl could merge only at the end.
          final HashSet<FacetRequest> handledRequests = new HashSet<FacetRequest>();
          for (FacetRequest fr : searchParams.facetRequests) {
            // Handle and merge only facet requests which were not already handled. 
            if (handledRequests.add(fr)) {
              PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
              IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(offset);
              IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
              if (oldRes != null) {
                res4fr = frHndlr.mergeResults(oldRes, res4fr);
              }
              fr2tmpRes.put(fr, res4fr);
            }
          }
        }
      } finally {
        facetArrays.free();
      }

      // gather results from all requests into a list for returning them
      List<FacetResult> res = new ArrayList<FacetResult>();
      for (FacetRequest fr : searchParams.facetRequests) {
        PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
        IntermediateFacetResult tmpResult = fr2tmpRes.get(fr);
        if (tmpResult == null) {
          // Add empty FacetResult:
          FacetResultNode root = new FacetResultNode();
          root.ordinal = TaxonomyReader.INVALID_ORDINAL;
          root.label = fr.categoryPath;
          root.value = 0;
          res.add(new FacetResult(fr, root, 0));
          continue;
        }
        FacetResult facetRes = frHndlr.renderFacetResult(tmpResult);
        // final labeling if allowed (because labeling is a costly operation)
        frHndlr.labelResult(facetRes);
        res.add(facetRes);
      }

      return res;
    }
View Full Code Here

    List<FacetResult> sampleRes = super.accumulate(docids);
   
    List<FacetResult> results = new ArrayList<FacetResult>();
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fres.getFacetRequest());
      if (samplerFixer != null) {
        // fix the result of current request
        samplerFixer.fixResult(docids, fres, samplingRatio);
       
        fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any arranging it needs to

        if (shouldOversample) {
          // Using the sampler to trim the extra (over-sampled) results
          fres = sampler.trimResult(fres);
        }
      }
     
      // final labeling if allowed (because labeling is a costly operation)
      if (fres.getFacetResultNode().ordinal == TaxonomyReader.INVALID_ORDINAL) {
        // category does not exist, add an empty result
        results.add(emptyResult(fres.getFacetResultNode().ordinal, fres.getFacetRequest()));
      } else {
        frh.labelResult(fres);
        results.add(fres);
      }
    }
   
    searchParams = original; // Back to original params
View Full Code Here

          // but other impl could merge only at the end.
          final HashSet<FacetRequest> handledRequests = new HashSet<FacetRequest>();
          for (FacetRequest fr : searchParams.facetRequests) {
            // Handle and merge only facet requests which were not already handled. 
            if (handledRequests.add(fr)) {
              PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
              IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(offset);
              IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
              if (oldRes != null) {
                res4fr = frHndlr.mergeResults(oldRes, res4fr);
              }
              fr2tmpRes.put(fr, res4fr);
            }
          }
        }
      } finally {
        facetArrays.free();
      }

      // gather results from all requests into a list for returning them
      List<FacetResult> res = new ArrayList<FacetResult>();
      for (FacetRequest fr : searchParams.facetRequests) {
        PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
        IntermediateFacetResult tmpResult = fr2tmpRes.get(fr);
        if (tmpResult == null) {
          // Add empty FacetResult:
          res.add(emptyResult(taxonomyReader.getOrdinal(fr.categoryPath), fr));
          continue;
        }
        FacetResult facetRes = frHndlr.renderFacetResult(tmpResult);
        // final labeling if allowed (because labeling is a costly operation)
        frHndlr.labelResult(facetRes);
        res.add(facetRes);
      }

      return res;
    }
View Full Code Here

    List<FacetResult> results = new ArrayList<FacetResult>();
    SampleFixer sampleFixer = sampler.samplingParams.getSampleFixer();
   
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fres.getFacetRequest());
      if (sampleFixer != null) {
        // fix the result of current request
        sampleFixer.fixResult(docids, fres, sampleSet.actualSampleRatio);
        fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any
      }
     
      if (shouldOversample) {
        // Using the sampler to trim the extra (over-sampled) results
        fres = sampler.trimResult(fres);
      }
     
      // final labeling if allowed (because labeling is a costly operation)
      if (fres.getFacetResultNode().ordinal == TaxonomyReader.INVALID_ORDINAL) {
        // category does not exist, add an empty result
        results.add(emptyResult(fres.getFacetResultNode().ordinal, fres.getFacetRequest()));
      } else {
        frh.labelResult(fres);
        results.add(fres);
      }
    }

    if (shouldOversample) {
View Full Code Here

          // but other impl could merge only at the end.
          final HashSet<FacetRequest> handledRequests = new HashSet<FacetRequest>();
          for (FacetRequest fr : searchParams.facetRequests) {
            // Handle and merge only facet requests which were not already handled. 
            if (handledRequests.add(fr)) {
              PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
              IntermediateFacetResult res4fr = frHndlr.fetchPartitionResult(offset);
              IntermediateFacetResult oldRes = fr2tmpRes.get(fr);
              if (oldRes != null) {
                res4fr = frHndlr.mergeResults(oldRes, res4fr);
              }
              fr2tmpRes.put(fr, res4fr);
            }
          }
        }
      } finally {
        facetArrays.free();
      }

      // gather results from all requests into a list for returning them
      List<FacetResult> res = new ArrayList<FacetResult>();
      for (FacetRequest fr : searchParams.facetRequests) {
        PartitionsFacetResultsHandler frHndlr = createFacetResultsHandler(fr);
        IntermediateFacetResult tmpResult = fr2tmpRes.get(fr);
        if (tmpResult == null) {
          // Add empty FacetResult:
          res.add(emptyResult(taxonomyReader.getOrdinal(fr.categoryPath), fr));
          continue;
        }
        FacetResult facetRes = frHndlr.renderFacetResult(tmpResult);
        // final labeling if allowed (because labeling is a costly operation)
        frHndlr.labelResult(facetRes);
        res.add(facetRes);
      }

      return res;
    }
View Full Code Here

    List<FacetResult> sampleRes = delegee.accumulate(sampleSet.docids);

    List<FacetResult> fixedRes = new ArrayList<FacetResult>();
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fres.getFacetRequest());
      // fix the result of current request
      sampler.getSampleFixer(indexReader, taxonomyReader, searchParams).fixResult(docids, fres);
      fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any
     
      // Using the sampler to trim the extra (over-sampled) results
      fres = sampler.trimResult(fres);
     
      // final labeling if allowed (because labeling is a costly operation)
      frh.labelResult(fres);
      fixedRes.add(fres); // add to final results
    }

    delegee.searchParams = original; // Back to original params
   
View Full Code Here

    List<FacetResult> sampleRes = super.accumulate(docids);
   
    List<FacetResult> fixedRes = new ArrayList<FacetResult>();
    for (FacetResult fres : sampleRes) {
      // for sure fres is not null because this is guaranteed by the delegee.
      PartitionsFacetResultsHandler frh = createFacetResultsHandler(fres.getFacetRequest());
      // fix the result of current request
      sampler.getSampleFixer(indexReader, taxonomyReader, searchParams).fixResult(docids, fres);
     
      fres = frh.rearrangeFacetResult(fres); // let delegee's handler do any arranging it needs to

      // Using the sampler to trim the extra (over-sampled) results
      fres = sampler.trimResult(fres);

      // final labeling if allowed (because labeling is a costly operation)
      frh.labelResult(fres);
      fixedRes.add(fres); // add to final results
    }
   
    searchParams = original; // Back to original params
   
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.partitions.PartitionsFacetResultsHandler

Copyright © 2018 www.massapicom. 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.