public TermsLongFacetExecutor( IndexNumericFieldData indexFieldData, int size, int shardSize, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, SearchScript script, CacheRecycler cacheRecycler) { this.indexFieldData = indexFieldData; this.size = size; this.shardSize = shardSize; this.comparatorType = comparatorType; this.script = script; this.excluded = excluded; this.facets = cacheRecycler.longIntMap(-1); if (allTerms) { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { int maxDoc = readerContext.reader().maxDoc(); LongValues values = indexFieldData.load(readerContext).getLongValues(); for (int docId = 0; docId < maxDoc; docId++) { final int numValues = values.setDocument(docId); final LongIntOpenHashMap v = facets.v(); for (int i = 0; i < numValues; i++) { v.putIfAbsent(values.nextValue(), 0); } } } } }
@Override public void onValue(int docId, long value) { facets.addTo(value, 1); }