Goes through the first buckets, picking out candidate records and
tallying up their scores.
@return the index of the first bucket we did not process
546962
private int collectCandidates(Map<Long, Score> candidates,
                                List<Bucket> buckets,
                                int threshold) {
    int ix;
    for (ix = 0; ix < threshold &&
           candidates.size() < (CUTOFF_FACTOR_1 * max_search_hits); ix++) {
      Bucket b = buckets.get(ix);
      long[] ids = b.records;
      double score = b.getScore();
      
      for (int ix2 = 0; ix2 < b.nextfree; ix2++) {
        Score s = candidates.get(ids[ix2]);
        if (s == null) {
          s = new Score(ids[ix2]);
          candidates.put(ids[ix2], s);
        }
        s.score += score;
      }
      if (DEBUG)
        System.out.println("Bucket " + b.nextfree + " -> " + candidates.size());
    }
    return ix;
  }
195194
public synchronized TreeEntry<K, V> pollFirstEntry() {
		final TreeEntry<K, V> entry = firstEntry();
		if (entry != null) {
			remove(entry.getKey());
		}
		return entry;
	}
1062200
public double get(double index) {
        ListIterator<Bucket> b = buckets_.listIterator(0);
        ListIterator<Bucket> e = buckets_.listIterator(buckets_.size());

        while (b.nextIndex() < e.previousIndex()) {
            final ListIterator<Bucket> mid = buckets_.listIterator(b.nextIndex() / 2 + e.nextIndex() / 2);
            final Bucket mid_bucket = mid.next();
            mid.previous();  // Undo position change made by mid.next().

            if (mid_bucket.getRunningEventsCount() == index && mid.nextIndex() >= e.previousIndex()) {
                return mid_bucket.getRange().getCeil();
            } else if (mid_bucket.getRunningEventsCount() <= index) {
                b = mid;
                b.next();
            } else if (mid_bucket.getRunningEventsCount() - mid_bucket.getEvents() > index) {
                e = mid;
            } else {
                b = mid;
                break;
            }
        }

        final Bucket bucket = b.next();
        b.previous();  // Undo position change made by b.next().
        final double low = bucket.getRunningEventsCount() - bucket.getEvents();
        final double off = index - low;
        final double left_fraction = off / bucket.getEvents();
        final double right_fraction = 1 - left_fraction;
        return bucket.getRange().getCeil() * left_fraction + bucket.getRange().getFloor() * right_fraction;
    }
1194627
private Collection<JobInProgress> getInitedJobs() {
    Collection<JobInProgress> runningJobs = jobTracker.getRunningJobs();
    for (Iterator<JobInProgress> it = runningJobs.iterator(); it.hasNext();) {
      JobInProgress job = it.next();
      if (!job.inited()) {
        it.remove();
      }
    }
    return runningJobs;
  }
492699
public BigInteger getTotalCounts(){
		BigInteger result = BigInteger.ZERO;
		for (AtomicLong c: counters.getMap().values()){
			result = result.add(BigInteger.valueOf(c.get()));
		}
		return result;
	}
735888
public java.util.List<Bucket> getBuckets() {
        if (buckets == null) {
            buckets = new com.amazonaws.internal.SdkInternalList<Bucket>();
        }
        return buckets;
    }
744573
public ExplorationStep next() {
		if (this.candidates == null) {
			return null;
		}

		while (true) {
			int candidate = this.candidates.next();

			if (candidate < 0) {
				return null;
			}

			try {
				if (this.selectChain == null || this.selectChain.select(candidate, this)) {
					TransactionsIterable support = this.dataset.getSupport(candidate);

					// System.out.println("extending "+Arrays.toString(this.pattern)+
					// " with "+
					// candidate+" ("+this.counters.getReverseRenaming()[candidate]+")");

					Counters candidateCounts = new Counters(this.counters.minSupport, support.iterator(),
							candidate, this.counters.maxFrequent);

					int greatest = Integer.MIN_VALUE;
					for (int i = 0; i < candidateCounts.closure.length; i++) {
						if (candidateCounts.closure[i] > greatest) {
							greatest = candidateCounts.closure[i];
						}
					}

					if (greatest > candidate) {
						throw new WrongFirstParentException(candidate, greatest);
					}

					// instanciateDataset may choose to compress renaming - if
					// not, at least it's set for now.
					candidateCounts.reuseRenaming(this.counters.reverseRenaming);

					return new ExplorationStep(this, candidate, candidateCounts, support);
				}
			} catch (WrongFirstParentException e) {
				addFailedFPTest(e.extension, e.firstParent);
			}
		}
	}
779175
private Set<Integer> obtainCandidates(double[] q) {
        Set<Integer> candidates = new LinkedHashSet<>();
        for (Hash h : hash) {
            BucketEntry bucket = h.get(q);
            if (bucket != null) {
                int m = bucket.entry.size();
                for (int i = 0; i < m; i++) {
                    int index = bucket.entry.get(i);
                    candidates.add(index);
                }
            }
        }
        return candidates;
    }
1201898
public AlphabeticIndex<V> clearRecords() {
        if (inputList != null && !inputList.isEmpty()) {
            inputList.clear();
            buckets = null;
        }
        return this;
    }
156851
public synchronized Map<String, Integer> getStats() {
    Map<String, Integer> stats = new HashMap<String, Integer>();
    for (int i = 0; i < mBuckets.size(); ++i) {
      final int bucketedSize = mBuckets.keyAt(i);
      final Bucket<V> bucket = mBuckets.valueAt(i);
      final String BUCKET_USED_KEY =
          PoolStatsTracker.BUCKETS_USED_PREFIX + getSizeInBytes(bucketedSize);
      stats.put(BUCKET_USED_KEY, bucket.getInUseCount());
    }

    stats.put(PoolStatsTracker.SOFT_CAP, mPoolParams.maxSizeSoftCap);
    stats.put(PoolStatsTracker.HARD_CAP, mPoolParams.maxSizeHardCap);
    stats.put(PoolStatsTracker.USED_COUNT, mUsed.mCount);
    stats.put(PoolStatsTracker.USED_BYTES, mUsed.mNumBytes);
    stats.put(PoolStatsTracker.FREE_COUNT, mFree.mCount);
    stats.put(PoolStatsTracker.FREE_BYTES, mFree.mNumBytes);

    return stats;
  }
694172
private int binarySearch(T record) {
		int low = 0;
		int high = this.boundaries.length - 1;
		typeComparator.extractKeys(record, keys, 0);

		while (low <= high) {
			final int mid = (low + high) >>> 1;
			final int result = compareKeys(flatComparators, keys, this.boundaries[mid]);

			if (result > 0) {
				low = mid + 1;
			} else if (result < 0) {
				high = mid - 1;
			} else {
				return mid;
			}
		}
		// key not found, but the low index is the target
		// bucket, since the boundaries are the upper bound
		return low;
	}
1307449
public int[] getBestAssignment() {
    double maxValue = Double.NEGATIVE_INFINITY;
    for (int i = 0; i < values.length; i++) if (values[i] > maxValue) {
      maxValue = values[i];
    }

    // OPTIMIZATION:
    // Rather than use the standard iterator, which creates lots of int[] arrays on the heap, which need to be GC'd,
    // we use the fast version that just mutates one array. Since this is read once for us here, this is ideal.

    Iterator<int[]> fastPassByReferenceIterator = fastPassByReferenceIterator();
    do {
      int[] assignment = fastPassByReferenceIterator.next();
      double v = getAssignmentLogValue(assignment);
      if (v == maxValue) return assignment;
    } while (fastPassByReferenceIterator.hasNext());

    throw new IllegalStateException("This is unreachable.");
  }
39253
public T first() {
        Iterator<T> iterator = iterator();
        return (iterator.hasNext() ? iterator.next() : null);
    }
916660
public HelpTopicNode getPreviousSibling() {
        int i = getIndex() - 1;
        return i < 0 ? null : parent.children.get(i);
    }
902955
public int getPriority()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getPriority");
    int priority = _sourceStream.getPriority();
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getPriority", new Integer(priority));
    return priority;
  }
978908
public int getPreviousRemaining() {
        int remaining = mPrevRemaining;
        if (remaining < 0) {
            mPrevRemaining = remaining =
                ((mPrev == null) ? 0 : (mPrev.getPreviousRemaining() + 1));
        }
        return remaining;
    }
1175854
public Record getMainRecord()
    {
        Record record = null;
        if (this.size() > 0)
        {
            record = (Record)this.firstElement();
            if (record != null) if (record == this.getScreenRecord())
            {
                record = null;
                if (this.size() >= 2)
                    record = (Record)this.elementAt(1);
            }
        }
        return record;
    }