Java Code Examples for org.apache.lucene.search.DocIdSetIterator#cost()
The following examples show how to use
org.apache.lucene.search.DocIdSetIterator#cost() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SparseFixedBitSet.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void or(DocIdSetIterator it) throws IOException { { // specialize union with another SparseFixedBitSet final SparseFixedBitSet other = BitSetIterator.getSparseFixedBitSetOrNull(it); if (other != null) { checkUnpositioned(it); or(other); return; } } // We do not specialize the union with a FixedBitSet since FixedBitSets are // supposed to be used for dense data and sparse fixed bit sets for sparse // data, so a sparse set would likely get upgraded by DocIdSetBuilder before // being or'ed with a FixedBitSet if (it.cost() < indices.length) { // the default impl is good for sparse iterators super.or(it); } else { orDense(it); } }
Example 2
Source File: ProfileScorer.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public DocIdSetIterator iterator() { final DocIdSetIterator in = scorer.iterator(); return new DocIdSetIterator() { @Override public int advance(int target) throws IOException { profile.startTime(ProfileBreakdown.TimingType.ADVANCE); try { return in.advance(target); } finally { profile.stopAndRecordTime(); } } @Override public int nextDoc() throws IOException { profile.startTime(ProfileBreakdown.TimingType.NEXT_DOC); try { return in.nextDoc(); } finally { profile.stopAndRecordTime(); } } @Override public int docID() { return in.docID(); } @Override public long cost() { return in.cost(); } }; }
Example 3
Source File: BitSet.java From lucene-solr with Apache License 2.0 | 5 votes |
/** Build a {@link BitSet} from the content of the provided {@link DocIdSetIterator}. * NOTE: this will fully consume the {@link DocIdSetIterator}. */ public static BitSet of(DocIdSetIterator it, int maxDoc) throws IOException { final long cost = it.cost(); final int threshold = maxDoc >>> 7; BitSet set; if (cost < threshold) { set = new SparseFixedBitSet(maxDoc); } else { set = new FixedBitSet(maxDoc); } set.or(it); return set; }
Example 4
Source File: DocValuesFacets.java From lucene-solr with Apache License 2.0 | 5 votes |
/** accumulates per-segment single-valued facet counts */ static void accumSingle(int counts[], int startTermIndex, SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException { if (startTermIndex == -1 && (map == null || si.getValueCount() < disi.cost()*10)) { // no prefixing, not too many unique values wrt matching docs (lucene/facets heuristic): // collect separately per-segment, then map to global ords accumSingleSeg(counts, si, disi, subIndex, map); } else { // otherwise: do collect+map on the fly accumSingleGeneric(counts, startTermIndex, si, disi, subIndex, map); } }
Example 5
Source File: DocValuesFacets.java From lucene-solr with Apache License 2.0 | 5 votes |
/** accumulates per-segment multi-valued facet counts */ static void accumMulti(int counts[], int startTermIndex, SortedSetDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException { if (startTermIndex == -1 && (map == null || si.getValueCount() < disi.cost()*10)) { // no prefixing, not too many unique values wrt matching docs (lucene/facets heuristic): // collect separately per-segment, then map to global ords accumMultiSeg(counts, si, disi, subIndex, map); } else { // otherwise: do collect+map on the fly accumMultiGeneric(counts, startTermIndex, si, disi, subIndex, map); } }
Example 6
Source File: ProfileScorer.java From crate with Apache License 2.0 | 5 votes |
@Override public DocIdSetIterator iterator() { if (isConstantScoreQuery) { return scorer.iterator(); } final DocIdSetIterator in = scorer.iterator(); return new DocIdSetIterator() { @Override public int advance(int target) throws IOException { advanceTimer.start(); try { return in.advance(target); } finally { advanceTimer.stop(); } } @Override public int nextDoc() throws IOException { nextDocTimer.start(); try { return in.nextDoc(); } finally { nextDocTimer.stop(); } } @Override public int docID() { return in.docID(); } @Override public long cost() { return in.cost(); } }; }