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


Java DocIdSetIterator.NO_MORE_DOCS属性代码示例

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


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

示例1: buildFromTerms

/**
 * This method iterates all terms in the given {@link TermsEnum} and
 * associates each terms ordinal with the terms documents. The caller must
 * exhaust the returned {@link BytesRefIterator} which returns all values
 * where the first returned value is associated with the ordinal <tt>1</tt>
 * etc.
 * <p>
 * If the {@link TermsEnum} contains prefix coded numerical values the terms
 * enum should be wrapped with either {@link #wrapNumeric32Bit(TermsEnum)}
 * or {@link #wrapNumeric64Bit(TermsEnum)} depending on its precision. If
 * the {@link TermsEnum} is not wrapped the returned
 * {@link BytesRefIterator} will contain partial precision terms rather than
 * only full-precision terms.
 * </p>
 */
public BytesRefIterator buildFromTerms(final TermsEnum termsEnum) throws IOException {
    return new BytesRefIterator() {
        private PostingsEnum docsEnum = null;

        @Override
        public BytesRef next() throws IOException {
            BytesRef ref;
            if ((ref = termsEnum.next()) != null) {
                docsEnum = termsEnum.postings(docsEnum, PostingsEnum.NONE);
                nextOrdinal();
                int docId;
                while ((docId = docsEnum.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
                    addDoc(docId);
                }
            }
            return ref;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:OrdinalsBuilder.java

示例2: lookup

/** Return null if id is not found. */
public DocIdAndVersion lookup(BytesRef id, Bits liveDocs, LeafReaderContext context) throws IOException {
    if (termsEnum.seekExact(id)) {
        // there may be more than one matching docID, in the case of nested docs, so we want the last one:
        docsEnum = termsEnum.postings(docsEnum, 0);
        int docID = DocIdSetIterator.NO_MORE_DOCS;
        for (int d = docsEnum.nextDoc(); d != DocIdSetIterator.NO_MORE_DOCS; d = docsEnum.nextDoc()) {
            if (liveDocs != null && liveDocs.get(d) == false) {
                continue;
            }
            docID = d;
        }

        if (docID != DocIdSetIterator.NO_MORE_DOCS) {
            return new DocIdAndVersion(docID, versions.get(docID), context);
        }
    }

    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:PerThreadIDAndVersionLookup.java

示例3: buildFromTerms

/**
 * This method iterates all terms in the given {@link TermsEnum} and
 * associates each terms ordinal with the terms documents. The caller must
 * exhaust the returned {@link BytesRefIterator} which returns all values
 * where the first returned value is associted with the ordinal <tt>1</tt>
 * etc.
 * <p>
 * If the {@link TermsEnum} contains prefix coded numerical values the terms
 * enum should be wrapped with either {@link #wrapNumeric32Bit(TermsEnum)}
 * or {@link #wrapNumeric64Bit(TermsEnum)} depending on its precision. If
 * the {@link TermsEnum} is not wrapped the returned
 * {@link BytesRefIterator} will contain partial precision terms rather than
 * only full-precision terms.
 * </p>
 */
public BytesRefIterator buildFromTerms(final TermsEnum termsEnum) throws IOException {
    return new BytesRefIterator() {
        private PostingsEnum docsEnum = null;

        @Override
        public BytesRef next() throws IOException {
            BytesRef ref;
            if ((ref = termsEnum.next()) != null) {
                docsEnum = termsEnum.postings(docsEnum, PostingsEnum.NONE);
                nextOrdinal();
                int docId;
                while ((docId = docsEnum.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
                    addDoc(docId);
                }
            }
            return ref;
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:34,代码来源:OrdinalsBuilder.java

示例4: scorer

@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
    final Scorer parentScorer = parentWeight.scorer(context);

    // no matches
    if (parentScorer == null) {
        return null;
    }

    BitSet parents = parentsFilter.getBitSet(context);
    if (parents == null) {
        // No matches
        return null;
    }

    int firstParentDoc = parentScorer.iterator().nextDoc();
    if (firstParentDoc == DocIdSetIterator.NO_MORE_DOCS) {
        // No matches
        return null;
    }
    return new IncludeNestedDocsScorer(this, parentScorer, parents, firstParentDoc);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:IncludeNestedDocsQuery.java

示例5: nextDoc

@Override
int nextDoc() {
  if (idx >= size) {
    offset = -1;
    return doc = DocIdSetIterator.NO_MORE_DOCS;
  }
  doc = (int) docs.get(idx);
  ++idx;
  while (idx < size && docs.get(idx) == doc) {
    ++idx;
  }
  // idx points to the "next" element
  long prevIdx = idx - 1;
  // cannot change 'value' here because nextDoc is called before the
  // value is used, and it's a waste to clone the BytesRef when we
  // obtain the value
  offset = (int) offsets.get(prevIdx);
  length = (int) lengths.get(prevIdx);
  return doc;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:BinaryDocValuesFieldUpdates.java

示例6: nextDoc

public int nextDoc() throws IOException {
	int doc = DocIdSetIterator.NO_MORE_DOCS;
	while ((doc = nextDocAtomicContext()) == DocIdSetIterator.NO_MORE_DOCS) {
		if (!isAtLastContext()) {
			if (!initAtomicContextPositionsFreqs()) {
				return DocIdSetIterator.NO_MORE_DOCS;
			}
			continue;
		}
		break;
	}
	if (doc != DocIdSetIterator.NO_MORE_DOCS) {
		setupPerDoc();
	}
	return doc;
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:16,代码来源:AbstractJoin.java

示例7: execute

private void execute(ComputesBooleanResult join, IndexReader r,
		JoinType joinType, int queryId,
		Map<Integer, List<JoinType>> numDocsJoinType) throws IOException {
	int numResultDocs = 0;
	int docId = -1;
	long startTime = System.nanoTime();
	join.setup(r);
	docId = join.nextDoc();
	while (docId != DocIdSetIterator.NO_MORE_DOCS) {
		boolean matches = join.match();
		if (matches) {
			numResultDocs++;
		}
		docId = join.nextDoc();
	}
	long endTime = System.nanoTime();
	System.out.println(queryId + "," + joinType.getId() + ","
			+ numResultDocs + ","
			+ countingNPA.getCountingOperatorAware().getCount() + ","
			+ (endTime - startTime) / 1000000);
	if (!numDocsJoinType.containsKey(numResultDocs)) {
		numDocsJoinType.put(numResultDocs, new ArrayList<JoinType>());
	}
	numDocsJoinType.get(numResultDocs).add(joinType);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:25,代码来源:CorrectnessTest.java

示例8: printAvgTfInDocsWithAllTerms

private void printAvgTfInDocsWithAllTerms() throws IOException {
	DocIter docIter = new DocIter(query.labels());
	int numDocs = 0;
	docIter.setup(reader);
	int numQueryTerms = query.labels().length;
	long[] totals = new long[numQueryTerms];
	Arrays.fill(totals, 0);
	while (docIter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
		numDocs++;
		for (int i = 0; i < numQueryTerms; i++) {
			totals[i] += docIter.getTermFreq(i);
		}
	}
	if (numQueryTerms > 0) {
		StringBuilder builder = new StringBuilder();
		builder.append(format.format(totals[0] * 1.0 / numDocs));
		for (int j = 1; j < numQueryTerms; j++) {
			builder.append(",");
			builder.append(format.format(totals[j] * 1.0 / numDocs));
		}
		System.out.println(builder.toString());
	}
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:23,代码来源:TermFreqAnalyzer.java

示例9: execute

private void execute(ComputesBooleanResult join, IndexReader r,
		JoinType joinType, int queryId) throws IOException {
	int numResultDocs = 0;
	int docId = -1;
	long startTime = System.nanoTime();
	join.setup(r);
	docId = join.nextDoc();
	while (docId != DocIdSetIterator.NO_MORE_DOCS) {
		boolean matches = join.match();
		if (matches) {
			numResultDocs++;
		}
		docId = join.nextDoc();
	}
	long endTime = System.nanoTime();
	System.out.println(queryId + "," + joinType.getId() + ","
			+ numResultDocs + "," + (endTime - startTime) / 1000000);
}
 
开发者ID:arne-cl,项目名称:fangorn,代码行数:18,代码来源:CacheEffectTest.java

示例10: next

public boolean next() throws IOException {
  if (postings == null) {
    doc = DocIdSetIterator.NO_MORE_DOCS;
    return false;
  }
  doc = postings.nextDoc();
  if (doc == DocIdSetIterator.NO_MORE_DOCS) {
    return false;
  }
  freq = postings.freq();
  positions = new ArrayList<>();
  for (int i = 0; i < freq; i++) {
    positions.add(postings.nextPosition());
  }
  position = positions.get(0);
  return true;
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:17,代码来源:TermDocsEnum.java

示例11: buildEntryValue

private NamedList<Object> buildEntryValue(long count, Term t, List<Entry<LeafReader, Bits>> leaves) throws IOException {
  NamedList<Object> entry = new NamedList<>();
  entry.add("count", count);
  int i = -1;
  for (Entry<LeafReader, Bits> e : leaves) {
    PostingsEnum postings = e.getKey().postings(t, PostingsEnum.PAYLOADS);
    Bits liveDocs = e.getValue();
    while (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
      if (!liveDocs.get(postings.docID())) {
        continue;
      }
      i++;
      NamedList<Object> documentEntry = new NamedList<>();
      entry.add("doc" + i, documentEntry);
      for (int j = 0; j < postings.freq(); j++) {
        postings.nextPosition();
        String extra = postings.getPayload().utf8ToString();
        documentEntry.add("position" + j, extra);
      }
    }
  }
  return entry;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:23,代码来源:ProofOfConceptPayloadHandler.java

示例12: accumSingleSeg

/** "typical" single-valued faceting: not too many unique values, no prefixing. maps to global ordinals as a separate step */
static void accumSingleSeg(int counts[], SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  // First count in seg-ord space:
  final int segCounts[];
  if (map == null) {
    segCounts = counts;
  } else {
    segCounts = new int[1+si.getValueCount()];
  }
  
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    segCounts[1+si.getOrd(doc)]++;
  }
  
  // migrate to global ords (if necessary)
  if (map != null) {
    migrateGlobal(counts, segCounts, subIndex, map);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:20,代码来源:DocValuesFacets.java

示例13: accumMultiGeneric

/** accumulates per-segment multi-valued facet counts, mapping to global ordinal space on-the-fly */
static void accumMultiGeneric(int counts[], int startTermIndex, SortedSetDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  final LongValues ordMap = map == null ? null : map.getGlobalOrds(subIndex);
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    si.setDocument(doc);
    // strange do-while to collect the missing count (first ord is NO_MORE_ORDS)
    int term = (int) si.nextOrd();
    if (term < 0) {
      if (startTermIndex == -1) {
        counts[0]++; // missing count
      }
      continue;
    }
    
    do {
      if (map != null) {
        term = (int) ordMap.get(term);
      }
      int arrIdx = term-startTermIndex;
      if (arrIdx>=0 && arrIdx<counts.length) counts[arrIdx]++;
    } while ((term = (int) si.nextOrd()) >= 0);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:24,代码来源:DocValuesFacets.java

示例14: getFirstMatch

protected int getFirstMatch(IndexReader r, Term t) throws IOException {
  Fields fields = MultiFields.getFields(r);
  if (fields == null) return -1;
  Terms terms = fields.terms(t.field());
  if (terms == null) return -1;
  BytesRef termBytes = t.bytes();
  final TermsEnum termsEnum = terms.iterator(null);
  if (!termsEnum.seekExact(termBytes)) {
    return -1;
  }
  DocsEnum docs = termsEnum.docs(MultiFields.getLiveDocs(r), null, DocsEnum.FLAG_NONE);
  int id = docs.nextDoc();
  if (id != DocIdSetIterator.NO_MORE_DOCS) {
    int next = docs.nextDoc();
    assertEquals(DocIdSetIterator.NO_MORE_DOCS, next);
  }
  return id == DocIdSetIterator.NO_MORE_DOCS ? -1 : id;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:TestRTGBase.java

示例15: printDocIDs

@SuppressWarnings("unused")
private void printDocIDs(DocSet fromSet) throws IOException {
	// Only used in debugging.
	System.out.println("---------------------------");
	DocIterator iter = fromSet.iterator();
	while (iter.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
		Integer docId = iter.next();
		Document d = fromSearcher.doc(docId);
		String id = d.getValues("id")[0];
		// TODO :log message  (this is too verbose?)
		if (debug) {
			System.out.println("INTERNAL ID : " + docId + " DOC : " + id);
		}
	}
	System.out.println("---------------------------");
}
 
开发者ID:kwatters,项目名称:solrgraph,代码行数:16,代码来源:GraphQuery.java


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