示例#1
0
  /**
   * Adds refinement requests for the value for each shard that has not already contributed a count
   * for this value.
   */
  private void processDefiniteCandidateElement(PivotFacet pf, PivotFacetValue value) {

    for (int shard = pf.knownShards.nextSetBit(0);
        0 <= shard;
        shard = pf.knownShards.nextSetBit(shard + 1)) {
      if (!value.shardHasContributed(shard)) {
        if ( // if we're doing index order, we need to refine anything
        // (mincount may have excluded from a shard)
        FacetParams.FACET_SORT_INDEX.equals(facetFieldSort)
            // if we are doing count order, we need to refine if the limit was hit
            // (if not, the shard doesn't have the value or it would have returned already)
            || numberOfValuesContributedByShardWasLimitedByFacetFieldLimit(shard)) {

          pf.addRefinement(shard, value);
        }
      }
    }
  }
示例#2
0
  /**
   * Checks the {@link #lowestCountContributedbyShard} for each shard, combined with the counts we
   * already know, to see if this value is a viable candidate -- <b>Does not make sense when using
   * {@link FacetParams#FACET_SORT_INDEX}</b>
   *
   * @see #processDefiniteCandidateElement
   */
  private void processPossibleCandidateElement(
      PivotFacet pf, PivotFacetValue value, final int refinementThreshold) {

    assert FacetParams.FACET_SORT_COUNT.equals(facetFieldSort)
        : "Method only makes sense when sorting by count";

    int maxPossibleCountAfterRefinement = value.getCount();

    for (int shard = pf.knownShards.nextSetBit(0);
        0 <= shard;
        shard = pf.knownShards.nextSetBit(shard + 1)) {
      if (!value.shardHasContributed(shard)) {
        maxPossibleCountAfterRefinement += lowestCountContributedbyShard(shard);
      }
    }

    if (refinementThreshold <= maxPossibleCountAfterRefinement) {
      processDefiniteCandidateElement(pf, value);
    }
  }