/** * A recursive method for determining which {@link PivotFacetValue}s need to be refined for this * pivot. * * @see PivotFacet#queuePivotRefinementRequests */ public void queuePivotRefinementRequests(PivotFacet pf) { if (needRefinementAtThisLevel && !valueCollection.getExplicitValuesList().isEmpty()) { if (FacetParams.FACET_SORT_COUNT.equals(facetFieldSort)) { // we only need to things that are currently in our limit, // or might be in our limit if we get increased counts from shards that // didn't include this value the first time final int indexOfCountThreshold = Math.min( valueCollection.getExplicitValuesListSize(), facetFieldOffset + facetFieldLimit) - 1; final int countThreshold = valueCollection.getAt(indexOfCountThreshold).getCount(); int positionInResults = 0; for (PivotFacetValue value : valueCollection.getExplicitValuesList()) { if (positionInResults <= indexOfCountThreshold) { // This element is within the top results, so we need to get information // from all of the shards. processDefiniteCandidateElement(pf, value); } else { // This element is not within the top results, but may still need to be refined. processPossibleCandidateElement(pf, value, countThreshold); } positionInResults++; } } else { // FACET_SORT_INDEX // everything needs refined to see what the per-shard mincount excluded for (PivotFacetValue value : valueCollection.getExplicitValuesList()) { processDefiniteCandidateElement(pf, value); } } needRefinementAtThisLevel = false; } if (pf.isRefinementsRequired()) { // if any refinements are needed, then we need to stop and wait to // see how the picture may change before drilling down to child pivot fields return; } else { // Since outstanding requests have been filled, then we can drill down // to the next deeper level and check it. refineNextLevelOfFacets(pf); } }
/** * A recursive method for generating <code>NamedLists</code> from this field suitable for * including in a pivot facet response to the original distributed request. */ public List<NamedList<Object>> convertToListOfNamedLists() { List<NamedList<Object>> convertedPivotList = null; if (valueCollection.size() > 0) { convertedPivotList = new LinkedList<>(); for (PivotFacetValue pivot : valueCollection) convertedPivotList.add(pivot.convertToNamedList()); } return convertedPivotList; }
private void contributeValueFromShard( int shardNumber, ResponseBuilder rb, NamedList<Object> shardValue) { incrementShardValueCount(shardNumber); Comparable value = PivotFacetHelper.getValue(shardValue); int count = PivotFacetHelper.getCount(shardValue); // We're changing values so we most mark the collection as dirty valueCollection.markDirty(); if ((!shardLowestCount.containsKey(shardNumber)) || shardLowestCount.get(shardNumber) > count) { shardLowestCount.put(shardNumber, count); } PivotFacetValue facetValue = valueCollection.get(value); if (null == facetValue) { // never seen before, we need to create it from scratch facetValue = PivotFacetValue.createFromNamedList(shardNumber, rb, this, shardValue); this.valueCollection.add(facetValue); } else { facetValue.mergeContributionFromShard(shardNumber, rb, shardValue); } }
private void refineNextLevelOfFacets(PivotFacet pf) { List<PivotFacetValue> explicitValsToRefine = valueCollection.getNextLevelValuesToRefine(); for (PivotFacetValue value : explicitValsToRefine) { if (null != value.getChildPivot()) { value.getChildPivot().queuePivotRefinementRequests(pf); } } PivotFacetValue missing = this.valueCollection.getMissingValue(); if (null != missing && null != missing.getChildPivot()) { missing.getChildPivot().queuePivotRefinementRequests(pf); } }