I'm looking at org.apache.solr.request.NumericFacets.getCounts(), trying to get
an idea of how it works. Specifically looking at this bit of code:
final List<AtomicReaderContext> leaves = searcher.getIndexReader().leaves();
final Iterator<AtomicReaderContext> ctxIt = leaves.iterator();
for (DocIterator docsIt = docs.iterator(); docsIt.hasNext(); ) {
final int doc = docsIt.nextDoc();
if (ctx == null || doc >= ctx.docBase + ctx.reader().maxDoc()) {
do {
ctx = ctxIt.next();
} while (ctx == null || doc >= ctx.docBase + ctx.reader().maxDoc());
switch (numericType) {
case LONG:
longs = DocValues.getNumeric(ctx.reader(), fieldName);
Am I right that it is assuming that the docs are in order? This confused me
because the javadoc for DocIterator says "The order of the documents returned
by this iterator is non-deterministic". For most of the DocIterator
implementations, the docs are returned in order, which I guess is how this
works?
Also, am I right that it is assuming the index reader leaves are in order? That
is, each leaf has higher doc ids than the previous leaf? I'm wondering too if
that is always true, or if that is just how the implementation works now.
(I'm asking these questions because I want to do something very similar in a
custom bit of code I'm writing, and would be nice if I could safely make these
same assumptions.)
-Michael