List of usage examples for org.apache.lucene.search DocIdSetIterator NO_MORE_DOCS
int NO_MORE_DOCS
To view the source code for org.apache.lucene.search DocIdSetIterator NO_MORE_DOCS.
Click Source Link
From source file:org.apache.solr.search.DocSetBuilder.java
License:Apache License
public static void add(FixedBitSet bitSet, DocIdSetIterator iter, int base) throws IOException { for (int doc = iter.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iter.nextDoc()) { bitSet.set(doc + base);/* w w w . ja v a 2 s .c o m*/ } }
From source file:org.apache.solr.search.DocSetUtil.java
License:Apache License
private static DocSet createSmallSet(List<LeafReaderContext> leaves, PostingsEnum[] postList, int maxPossible, int firstReader) throws IOException { int[] docs = new int[maxPossible]; int sz = 0;// ww w. java 2 s . co m for (int i = firstReader; i < postList.length; i++) { PostingsEnum postings = postList[i]; if (postings == null) continue; LeafReaderContext ctx = leaves.get(i); Bits liveDocs = ctx.reader().getLiveDocs(); int base = ctx.docBase; for (;;) { int subId = postings.nextDoc(); if (subId == DocIdSetIterator.NO_MORE_DOCS) break; if (liveDocs != null && !liveDocs.get(subId)) continue; int globalId = subId + base; docs[sz++] = globalId; } } return new SortedIntDocSet(docs, sz); }
From source file:org.apache.solr.search.DocSetUtil.java
License:Apache License
private static DocSet createBigSet(List<LeafReaderContext> leaves, PostingsEnum[] postList, int maxDoc, int firstReader) throws IOException { long[] bits = new long[FixedBitSet.bits2words(maxDoc)]; int sz = 0;//from w w w . ja va2 s .co m for (int i = firstReader; i < postList.length; i++) { PostingsEnum postings = postList[i]; if (postings == null) continue; LeafReaderContext ctx = leaves.get(i); Bits liveDocs = ctx.reader().getLiveDocs(); int base = ctx.docBase; for (;;) { int subId = postings.nextDoc(); if (subId == DocIdSetIterator.NO_MORE_DOCS) break; if (liveDocs != null && !liveDocs.get(subId)) continue; int globalId = subId + base; bits[globalId >> 6] |= (1L << globalId); sz++; } } BitDocSet docSet = new BitDocSet(new FixedBitSet(bits, maxDoc), sz); int smallSetSize = smallSetSize(maxDoc); if (sz < smallSetSize) { // make this optional? DocSet smallSet = toSmallSet(docSet); // assert equals(docSet, smallSet); return smallSet; } return docSet; }
From source file:org.apache.solr.search.facet.BlockJoin.java
License:Apache License
/** childInput may also contain parents (i.e. a parent or below will all roll up to that parent) */ public static DocSet toParents(DocSet childInput, BitDocSet parentList, QueryContext qcontext) throws IOException { FixedBitSet parentBits = parentList.getBits(); DocSetCollector collector = new DocSetCollector(qcontext.searcher().maxDoc()); DocIterator iter = childInput.iterator(); int currentParent = -1; while (iter.hasNext()) { int childDoc = iter.nextDoc(); // TODO: skipping if (childDoc <= currentParent) { // use <= since we also allow parents in the input // we already visited this parent continue; }/*from w w w .j a v a 2 s.co m*/ currentParent = parentBits.nextSetBit(childDoc); if (currentParent != DocIdSetIterator.NO_MORE_DOCS) { // only collect the parent the first time we skip to it collector.collect(currentParent); } } return collector.getDocSet(); }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectPerSeg(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int segMax = singleDv.getValueCount() + 1; final int[] counts = getCountArr(segMax); /** alternate trial implementations // ord// w ww .ja va 2 s. c o m // FieldUtil.visitOrds(singleDv, disi, (doc,ord)->{counts[ord+1]++;} ); FieldUtil.OrdValues ordValues = FieldUtil.getOrdValues(singleDv, disi); while (ordValues.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { counts[ ordValues.getOrd() + 1]++; } **/ // calculate segment-local counts int doc; if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) { FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv; while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { counts[fc.getOrd(doc) + 1]++; } } else { while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (singleDv.advanceExact(doc)) { counts[singleDv.ordValue() + 1]++; } } } // convert segment-local counts to global counts for (int i = 1; i < segMax; i++) { int segCount = counts[i]; if (segCount > 0) { int slot = toGlobal == null ? (i - 1) : (int) toGlobal.get(i - 1); countAcc.incrementCount(slot, segCount); } } }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectPerSeg(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int segMax = (int) multiDv.getValueCount(); final int[] counts = getCountArr(segMax); int doc;// w ww.j a v a2s .c o m while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (multiDv.advanceExact(doc)) { for (;;) { int segOrd = (int) multiDv.nextOrd(); if (segOrd < 0) break; counts[segOrd]++; } } } for (int i = 0; i < segMax; i++) { int segCount = counts[i]; if (segCount > 0) { int slot = toGlobal == null ? (i) : (int) toGlobal.get(i); countAcc.incrementCount(slot, segCount); } } }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectDocs(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int doc;//from w w w . j a v a2s. c om while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (singleDv.advanceExact(doc)) { int segOrd = singleDv.ordValue(); collect(doc, segOrd, toGlobal); } } }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectCounts(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int doc;/*from ww w . java2 s . com*/ if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) { FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv; while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { int segOrd = fc.getOrd(doc); if (segOrd < 0) continue; int ord = (int) toGlobal.get(segOrd); countAcc.incrementCount(ord, 1); } } else { while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (singleDv.advanceExact(doc)) { int segOrd = singleDv.ordValue(); int ord = (int) toGlobal.get(segOrd); countAcc.incrementCount(ord, 1); } } } }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectDocs(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int doc;/*from www . j av a 2 s .c o m*/ while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (multiDv.advanceExact(doc)) { for (;;) { int segOrd = (int) multiDv.nextOrd(); if (segOrd < 0) break; collect(doc, segOrd, toGlobal); } } } }
From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java
License:Apache License
private void collectCounts(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException { int doc;/*from w w w .j a va 2 s. c om*/ while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (multiDv.advanceExact(doc)) { for (;;) { int segOrd = (int) multiDv.nextOrd(); if (segOrd < 0) break; int ord = (int) toGlobal.get(segOrd); countAcc.incrementCount(ord, 1); } } } }