当前位置: 首页>>代码示例>>Java>>正文


Java DocIdSetIterator.docID方法代码示例

本文整理汇总了Java中org.apache.lucene.search.DocIdSetIterator.docID方法的典型用法代码示例。如果您正苦于以下问题:Java DocIdSetIterator.docID方法的具体用法?Java DocIdSetIterator.docID怎么用?Java DocIdSetIterator.docID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.DocIdSetIterator的用法示例。


在下文中一共展示了DocIdSetIterator.docID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: or

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
/** Does in-place OR of the bits provided by the
 *  iterator. */
public void or(DocIdSetIterator iter) throws IOException {
  if (iter instanceof OpenBitSetIterator && iter.docID() == -1) {
    final OpenBitSetIterator obs = (OpenBitSetIterator) iter;
    or(obs.arr, obs.words);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    obs.advance(numBits);
  } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
    final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
    or(fbs.bits, fbs.numWords);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    fbs.advance(numBits);
  } else {
    int doc;
    while ((doc = iter.nextDoc()) < numBits) {
      set(doc);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:FixedBitSet.java

示例2: andNot

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
/** Does in-place AND NOT of the bits provided by the
 *  iterator. */
public void andNot(DocIdSetIterator iter) throws IOException {
  if (iter instanceof OpenBitSetIterator && iter.docID() == -1) {
    final OpenBitSetIterator obs = (OpenBitSetIterator) iter;
    andNot(obs.arr, obs.words);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    obs.advance(numBits);
  } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
    final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
    andNot(fbs.bits, fbs.numWords);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    fbs.advance(numBits);
  } else {
    int doc;
    while ((doc = iter.nextDoc()) < numBits) {
      clear(doc);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:FixedBitSet.java

示例3: getLeafCollector

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(final LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException {
    IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(ctx);
    IndexSearcher searcher = new IndexSearcher(topLevelContext);
    searcher.setQueryCache(null);
    Weight weight = searcher.createNormalizedWeight(childFilter, false);
    Scorer childDocsScorer = weight.scorer(ctx);

    final BitSet parentDocs = parentFilter.getBitSet(ctx);
    final DocIdSetIterator childDocs = childDocsScorer != null ? childDocsScorer.iterator() : null;
    return new LeafBucketCollectorBase(sub, null) {
        @Override
        public void collect(int parentDoc, long bucket) throws IOException {
            // if parentDoc is 0 then this means that this parent doesn't have child docs (b/c these appear always before the parent
            // doc), so we can skip:
            if (parentDoc == 0 || parentDocs == null || childDocs == null) {
                return;
            }

            final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1);
            int childDocId = childDocs.docID();
            if (childDocId <= prevParentDoc) {
                childDocId = childDocs.advance(prevParentDoc + 1);
            }

            for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) {
                collectBucket(sub, childDocId, bucket);
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:NestedAggregator.java

示例4: iterator

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public DocIdSetIterator iterator() {
    final DocIdSetIterator in = scorer.iterator();
    return new DocIdSetIterator() {

        @Override
        public int advance(int target) throws IOException {
            profile.startTime(QueryTimingType.ADVANCE);
            try {
                return in.advance(target);
            } finally {
                profile.stopAndRecordTime();
            }
        }

        @Override
        public int nextDoc() throws IOException {
            profile.startTime(QueryTimingType.NEXT_DOC);
            try {
                return in.nextDoc();
            } finally {
                profile.stopAndRecordTime();
            }
        }

        @Override
        public int docID() {
            return in.docID();
        }

        @Override
        public long cost() {
            return in.cost();
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:ProfileScorer.java

示例5: and

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
/** Does in-place AND of the bits provided by the
 *  iterator. */
public void and(DocIdSetIterator iter) throws IOException {
  if (iter instanceof OpenBitSetIterator && iter.docID() == -1) {
    final OpenBitSetIterator obs = (OpenBitSetIterator) iter;
    and(obs.arr, obs.words);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    obs.advance(numBits);
  } else if (iter instanceof FixedBitSetIterator && iter.docID() == -1) {
    final FixedBitSetIterator fbs = (FixedBitSetIterator) iter;
    and(fbs.bits, fbs.numWords);
    // advance after last doc that would be accepted if standard
    // iteration is used (to exhaust it):
    fbs.advance(numBits);
  } else {
    if (numBits == 0) return;
    int disiDoc, bitSetDoc = nextSetBit(0);
    while (bitSetDoc != -1 && (disiDoc = iter.advance(bitSetDoc)) < numBits) {
      clear(bitSetDoc, disiDoc);
      disiDoc++;
      bitSetDoc = (disiDoc < numBits) ? nextSetBit(disiDoc) : -1;
    }
    if (bitSetDoc != -1) {
      clear(bitSetDoc, numBits);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:FixedBitSet.java

示例6: iterator

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@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();
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:ProfileScorer.java

示例7: advanceSubIterators

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
private void advanceSubIterators(int target) throws IOException {
    if (target == NO_MORE_DOCS) {
        return;
    }
    for (DocIdSetIterator iterator: subIterators) {
        // FIXME: Probably inefficient
        if (iterator.docID() < target) {
            iterator.advance(target);
        }
    }
}
 
开发者ID:o19s,项目名称:elasticsearch-learning-to-rank,代码行数:12,代码来源:RankerQuery.java

示例8: scorer

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
private static Scorer scorer(int maxDoc, final int[] docs, final float[] scores, final boolean twoPhase) {
    final DocIdSetIterator iterator = twoPhase ? DocIdSetIterator.all(maxDoc) : iterator(docs);
    return new Scorer(null) {
        public DocIdSetIterator iterator() {
            if (twoPhase) {
                return TwoPhaseIterator.asDocIdSetIterator(twoPhaseIterator());
            } else {
                return iterator;
            }
        }

        public TwoPhaseIterator twoPhaseIterator() {
            if (twoPhase) {
                return new TwoPhaseIterator(iterator) {
                    
                    @Override
                    public boolean matches() throws IOException {
                        return Arrays.binarySearch(docs, iterator.docID()) >= 0;
                    }
                    
                    @Override
                    public float matchCost() {
                        return 10;
                    }
                };
            } else {
                return null;
            }
        }

        @Override
        public int docID() {
            return iterator.docID();
        }

        @Override
        public float score() throws IOException {
            final int idx = Arrays.binarySearch(docs, docID());
            return scores[idx];
        }

        @Override
        public int freq() throws IOException {
            return 1;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:48,代码来源:MinScoreScorerTests.java

示例9: createWeight

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    final Weight boundingBoxWeight;
    if (boundingBoxFilter != null) {
        boundingBoxWeight = searcher.createNormalizedWeight(boundingBoxFilter, false);
    } else {
        boundingBoxWeight = null;
    }
    return new ConstantScoreWeight(this) {
        @Override
        public Scorer scorer(LeafReaderContext context) throws IOException {
            final DocIdSetIterator approximation;
            if (boundingBoxWeight != null) {
                Scorer s = boundingBoxWeight.scorer(context);
                if (s == null) {
                    // if the approximation does not match anything, we're done
                    return null;
                }
                approximation = s.iterator();
            } else {
                approximation = DocIdSetIterator.all(context.reader().maxDoc());
            }
            final MultiGeoPointValues values = indexFieldData.load(context).getGeoPointValues();
            final TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(approximation) {
                @Override
                public boolean matches() throws IOException {
                    final int doc = approximation.docID();
                    values.setDocument(doc);
                    final int length = values.count();
                    for (int i = 0; i < length; i++) {
                        GeoPoint point = values.valueAt(i);
                        if (distanceBoundingCheck.isWithin(point.lat(), point.lon())) {
                            double d = fixedSourceDistance.calculate(point.lat(), point.lon());
                            if (d >= inclusiveLowerPoint && d <= inclusiveUpperPoint) {
                                return true;
                            }
                        }
                    }
                    return false;
                }

                @Override
                public float matchCost() {
                    if (distanceBoundingCheck == GeoDistance.ALWAYS_INSTANCE) {
                        return 0.0f;
                    } else {
                        // TODO: is this right (up to 4 comparisons from GeoDistance.SimpleDistanceBoundingCheck)?
                        return 4.0f;
                    }
                }
            };
            return new ConstantScoreScorer(this, score(), twoPhaseIterator);
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:56,代码来源:GeoDistanceRangeQuery.java

示例10: doQueryFirstScoring

import org.apache.lucene.search.DocIdSetIterator; //导入方法依赖的package包/类
/** Used when base query is highly constraining vs the
 *  drilldowns, or when the docs must be scored at once
 *  (i.e., like BooleanScorer2, not BooleanScorer).  In
 *  this case we just .next() on base and .advance() on
 *  the dim filters. */ 
private void doQueryFirstScoring(Collector collector, DocIdSetIterator[] disis, Collector[] sidewaysCollectors,
                                 Bits[] bits, Collector[] bitsSidewaysCollectors) throws IOException {
  //if (DEBUG) {
  //  System.out.println("  doQueryFirstScoring");
  //}
  int docID = baseScorer.docID();

  nextDoc: while (docID != DocsEnum.NO_MORE_DOCS) {
    Collector failedCollector = null;
    for (int i=0;i<disis.length;i++) {
      // TODO: should we sort this 2nd dimension of
      // docsEnums from most frequent to least?
      DocIdSetIterator disi = disis[i];
      if (disi != null && disi.docID() < docID) {
        disi.advance(docID);
      }
      if (disi == null || disi.docID() > docID) {
        if (failedCollector != null) {
          // More than one dim fails on this document, so
          // it's neither a hit nor a near-miss; move to
          // next doc:
          docID = baseScorer.nextDoc();
          continue nextDoc;
        } else {
          failedCollector = sidewaysCollectors[i];
        }
      }
    }

    // TODO: for the "non-costly Bits" we really should
    // have passed them down as acceptDocs, but
    // unfortunately we cannot distinguish today betwen
    // "bits() is so costly that you should apply it last"
    // from "bits() is so cheap that you should apply it
    // everywhere down low"

    // Fold in Filter Bits last, since they may be costly:
    for(int i=0;i<bits.length;i++) {
      if (bits[i].get(docID) == false) {
        if (failedCollector != null) {
          // More than one dim fails on this document, so
          // it's neither a hit nor a near-miss; move to
          // next doc:
          docID = baseScorer.nextDoc();
          continue nextDoc;
        } else {
          failedCollector = bitsSidewaysCollectors[i];
        }
      }
    }

    collectDocID = docID;

    // TODO: we could score on demand instead since we are
    // daat here:
    collectScore = baseScorer.score();

    if (failedCollector == null) {
      // Hit passed all filters, so it's "real":
      collectHit(collector, sidewaysCollectors, bitsSidewaysCollectors);
    } else {
      // Hit missed exactly one filter:
      collectNearMiss(failedCollector);
    }

    docID = baseScorer.nextDoc();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:74,代码来源:DrillSidewaysScorer.java


注:本文中的org.apache.lucene.search.DocIdSetIterator.docID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。