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


Java AtomicReaderContext类代码示例

本文整理汇总了Java中org.apache.lucene.index.AtomicReaderContext的典型用法代码示例。如果您正苦于以下问题:Java AtomicReaderContext类的具体用法?Java AtomicReaderContext怎么用?Java AtomicReaderContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: explain

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  Scorer scorer = scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = slop == 0 ? scorer.freq() : ((SloppyPhraseScorer)scorer).sloppyFreq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      ComplexExplanation result = new ComplexExplanation();
      result.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
      result.addDetail(scoreExplanation);
      result.setValue(scoreExplanation.getValue());
      result.setMatch(true);
      return result;
    }
  }
  
  return new ComplexExplanation(false, 0.0f, "no matching term");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PhraseQuery.java

示例2: explain

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  Scorer scorer = scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = scorer.freq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      ComplexExplanation result = new ComplexExplanation();
      result.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq));
      result.addDetail(scoreExplanation);
      result.setValue(scoreExplanation.getValue());
      result.setMatch(true);
      return result;
    }
  }
  return new ComplexExplanation(false, 0.0f, "no matching term");      
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:TermQuery.java

示例3: search

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
/**
 * Just like {@link #search(Weight, int, Sort, boolean, boolean)}, but you choose
 * whether or not the fields in the returned {@link FieldDoc} instances should
 * be set by specifying fillFields.
 */
protected TopFieldDocs search(List<AtomicReaderContext> leaves, Weight weight, FieldDoc after, int nDocs,
                              Sort sort, boolean fillFields, boolean doDocScores, boolean doMaxScore) throws IOException {
  // single thread
  int limit = reader.maxDoc();
  if (limit == 0) {
    limit = 1;
  }
  nDocs = Math.min(nDocs, limit);

  TopFieldCollector collector = TopFieldCollector.create(sort, nDocs, after,
                                                         fillFields, doDocScores,
                                                         doMaxScore, !weight.scoresDocsOutOfOrder());
  search(leaves, weight, collector);
  return (TopFieldDocs) collector.topDocs();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:IndexSearcher.java

示例4: NearSpansOrdered

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, Bits acceptDocs, Map<Term,TermContext> termContexts, boolean collectPayloads)
throws IOException {
  if (spanNearQuery.getClauses().length < 2) {
    throw new IllegalArgumentException("Less than 2 clauses: "
                                       + spanNearQuery);
  }
  this.collectPayloads = collectPayloads;
  allowedSlop = spanNearQuery.getSlop();
  SpanQuery[] clauses = spanNearQuery.getClauses();
  subSpans = new Spans[clauses.length];
  matchPayload = new LinkedList<>();
  subSpansByDoc = new Spans[clauses.length];
  for (int i = 0; i < clauses.length; i++) {
    subSpans[i] = clauses[i].getSpans(context, acceptDocs, termContexts);
    subSpansByDoc[i] = subSpans[i]; // used in toSameDoc()
  }
  query = spanNearQuery; // kept for toString() only.
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:NearSpansOrdered.java

示例5: explain

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  SpanScorer scorer = (SpanScorer) scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = scorer.sloppyFreq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      ComplexExplanation result = new ComplexExplanation();
      result.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
      result.addDetail(scoreExplanation);
      result.setValue(scoreExplanation.getValue());
      result.setMatch(true);          
      return result;
    }
  }
  
  return new ComplexExplanation(false, 0.0f, "no matching term");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:SpanWeight.java

示例6: filteredScorer

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Scorer filteredScorer(AtomicReaderContext context,
    Weight weight, DocIdSet docIdSet) throws IOException {
  final DocIdSetIterator filterIter = docIdSet.iterator();
  if (filterIter == null) {
    // this means the filter does not accept any documents.
    return null;
  }
  // we pass null as acceptDocs, as our filter has already respected acceptDocs, no need to do twice
  final Scorer scorer = weight.scorer(context, null);
  if (scorer == null) {
    return null;
  }

  if (scorerFirst) {
    return new LeapFrogScorer(weight, scorer, filterIter, scorer);  
  } else {
    return new LeapFrogScorer(weight, filterIter, scorer, scorer);  
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:FilteredQuery.java

示例7: create

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
/**
 * Creates a {@link CachingCollector} which does not wrap another collector.
 * The cached documents and scores can later be {@link #replay(Collector)
 * replayed}.
 * 
 * @param acceptDocsOutOfOrder
 *          whether documents are allowed to be collected out-of-order
 */
public static CachingCollector create(final boolean acceptDocsOutOfOrder, boolean cacheScores, double maxRAMMB) {
  Collector other = new Collector() {
    @Override
    public boolean acceptsDocsOutOfOrder() {
      return acceptDocsOutOfOrder;
    }
    
    @Override
    public void setScorer(Scorer scorer) {}

    @Override
    public void collect(int doc) {}

    @Override
    public void setNextReader(AtomicReaderContext context) {}

  };
  return create(other, cacheScores, maxRAMMB);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:CachingCollector.java

示例8: explain

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  Scorer scorer = scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = slop == 0 ? scorer.freq() : ((SloppyPhraseScorer)scorer).sloppyFreq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      ComplexExplanation result = new ComplexExplanation();
      result.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
      result.addDetail(scoreExplanation);
      result.setValue(scoreExplanation.getValue());
      result.setMatch(true);          
      return result;
    }
  }
  
  return new ComplexExplanation(false, 0.0f, "no matching term");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:MultiPhraseQuery.java

示例9: UnionDocsAndPositionsEnum

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
public UnionDocsAndPositionsEnum(Bits liveDocs, AtomicReaderContext context, Term[] terms, Map<Term,TermContext> termContexts, TermsEnum termsEnum) throws IOException {
  List<DocsAndPositionsEnum> docsEnums = new LinkedList<>();
  for (int i = 0; i < terms.length; i++) {
    final Term term = terms[i];
    TermState termState = termContexts.get(term).get(context.ord);
    if (termState == null) {
      // Term doesn't exist in reader
      continue;
    }
    termsEnum.seekExact(term.bytes(), termState);
    DocsAndPositionsEnum postings = termsEnum.docsAndPositions(liveDocs, null, DocsEnum.FLAG_NONE);
    if (postings == null) {
      // term does exist, but has no positions
      throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
    }
    cost += postings.cost();
    docsEnums.add(postings);
  }

  _queue = new DocsQueue(docsEnums);
  _posList = new IntQueue();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MultiPhraseQuery.java

示例10: getPayloads

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
    throws IOException {
  Map<Term,TermContext> termContexts = new HashMap<>();
  TreeSet<Term> terms = new TreeSet<>();
  query.extractTerms(terms);
  for (Term term : terms) {
    termContexts.put(term, TermContext.build(context, term));
  }
  for (AtomicReaderContext atomicReaderContext : context.leaves()) {
    final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
    while (spans.next() == true) {
      if (spans.isPayloadAvailable()) {
        Collection<byte[]> payload = spans.getPayload();
        for (byte [] bytes : payload) {
          payloads.add(bytes);
        }
      }
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PayloadSpanUtil.java

示例11: getDocIdSet

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, final Bits acceptDocs) throws IOException {
  final AtomicReader reader = context.reader();
  final Object key = reader.getCoreCacheKey();

  DocIdSet docIdSet = cache.get(key);
  if (docIdSet != null) {
    hitCount++;
  } else {
    missCount++;
    docIdSet = docIdSetToCache(filter.getDocIdSet(context, null), reader);
    assert docIdSet.isCacheable();
    cache.put(key, docIdSet);
  }

  return docIdSet == EMPTY ? null : BitsFilteredDocIdSet.wrap(docIdSet, acceptDocs);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:CachingWrapperFilter.java

示例12: scorer

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Scorer scorer(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  final DocIdSetIterator disi;
  if (filter != null) {
    assert query == null;
    final DocIdSet dis = filter.getDocIdSet(context, acceptDocs);
    if (dis == null) {
      return null;
    }
    disi = dis.iterator();
  } else {
    assert query != null && innerWeight != null;
    disi = innerWeight.scorer(context, acceptDocs);
  }

  if (disi == null) {
    return null;
  }
  return new ConstantScorer(disi, this, queryWeight);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:ConstantScoreQuery.java

示例13: explain

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  final Scorer cs = scorer(context, context.reader().getLiveDocs());
  final boolean exists = (cs != null && cs.advance(doc) == doc);

  final ComplexExplanation result = new ComplexExplanation();
  if (exists) {
    result.setDescription(ConstantScoreQuery.this.toString() + ", product of:");
    result.setValue(queryWeight);
    result.setMatch(Boolean.TRUE);
    result.addDetail(new Explanation(getBoost(), "boost"));
    result.addDetail(new Explanation(queryNorm, "queryNorm"));
  } else {
    result.setDescription(ConstantScoreQuery.this.toString() + " doesn't match id " + doc);
    result.setValue(0);
    result.setMatch(Boolean.FALSE);
  }
  return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ConstantScoreQuery.java

示例14: wrapCollector

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
private Collector wrapCollector(final Collector collector) {
  return new Collector() {
    @Override
    public void setScorer(Scorer scorer) throws IOException {
      // we must wrap again here, but using the scorer passed in as parameter:
      collector.setScorer(new ConstantScorer(scorer, weight, theScore));
    }
    
    @Override
    public void collect(int doc) throws IOException {
      collector.collect(doc);
    }
    
    @Override
    public void setNextReader(AtomicReaderContext context) throws IOException {
      collector.setNextReader(context);
    }
    
    @Override
    public boolean acceptsDocsOutOfOrder() {
      return collector.acceptsDocsOutOfOrder();
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:ConstantScoreQuery.java

示例15: scorer

import org.apache.lucene.index.AtomicReaderContext; //导入依赖的package包/类
/** Create the scorer used to score our associated DisjunctionMaxQuery */
@Override
public Scorer scorer(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  List<Scorer> scorers = new ArrayList<>();
  for (Weight w : weights) {
    // we will advance() subscorers
    Scorer subScorer = w.scorer(context, acceptDocs);
    if (subScorer != null) {
      scorers.add(subScorer);
    }
  }
  if (scorers.isEmpty()) {
    // no sub-scorers had any documents
    return null;
  } else if (scorers.size() == 1) {
    // only one sub-scorer in this segment
    return scorers.get(0);
  } else {
    return new DisjunctionMaxScorer(this, tieBreakerMultiplier, scorers.toArray(new Scorer[scorers.size()]));
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:DisjunctionMaxQuery.java


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