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


Java AtomicReader.getTermVectors方法代码示例

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


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

示例1: merge

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
/** Merges in the term vectors from the readers in 
 *  <code>mergeState</code>. The default implementation skips
 *  over deleted documents, and uses {@link #startDocument(int)},
 *  {@link #startField(FieldInfo, int, boolean, boolean, boolean)}, 
 *  {@link #startTerm(BytesRef, int)}, {@link #addPosition(int, int, int, BytesRef)},
 *  and {@link #finish(FieldInfos, int)},
 *  returning the number of documents that were written.
 *  Implementations can override this method for more sophisticated
 *  merging (bulk-byte copying, etc). */
public int merge(MergeState mergeState) throws IOException {
  int docCount = 0;
  for (int i = 0; i < mergeState.readers.size(); i++) {
    final AtomicReader reader = mergeState.readers.get(i);
    final int maxDoc = reader.maxDoc();
    final Bits liveDocs = reader.getLiveDocs();

    for (int docID = 0; docID < maxDoc; docID++) {
      if (liveDocs != null && !liveDocs.get(docID)) {
        // skip deleted docs
        continue;
      }
      // NOTE: it's very important to first assign to vectors then pass it to
      // termVectorsWriter.addAllDocVectors; see LUCENE-1282
      Fields vectors = reader.getTermVectors(docID);
      addAllDocVectors(vectors, mergeState);
      docCount++;
      mergeState.checkAbort.work(300);
    }
  }
  finish(mergeState.fieldInfos, docCount);
  return docCount;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:TermVectorsWriter.java

示例2: copyVectorsNoDeletions

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private int copyVectorsNoDeletions(MergeState mergeState,
                                    final Lucene40TermVectorsReader matchingVectorsReader,
                                    final AtomicReader reader,
                                    int rawDocLengths[],
                                    int rawDocLengths2[])
        throws IOException {
  final int maxDoc = reader.maxDoc();
  if (matchingVectorsReader != null) {
    // We can bulk-copy because the fieldInfos are "congruent"
    int docCount = 0;
    while (docCount < maxDoc) {
      int len = Math.min(MAX_RAW_MERGE_DOCS, maxDoc - docCount);
      matchingVectorsReader.rawDocs(rawDocLengths, rawDocLengths2, docCount, len);
      addRawDocuments(matchingVectorsReader, rawDocLengths, rawDocLengths2, len);
      docCount += len;
      mergeState.checkAbort.work(300 * len);
    }
  } else {
    for (int docNum = 0; docNum < maxDoc; docNum++) {
      // NOTE: it's very important to first assign to vectors then pass it to
      // termVectorsWriter.addAllDocVectors; see LUCENE-1282
      Fields vectors = reader.getTermVectors(docNum);
      addAllDocVectors(vectors, mergeState);
      mergeState.checkAbort.work(300);
    }
  }
  return maxDoc;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:Lucene40TermVectorsWriter.java

示例3: copyVectorsWithDeletions

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private int copyVectorsWithDeletions(MergeState mergeState,
                                      final Lucene40TermVectorsReader matchingVectorsReader,
                                      final AtomicReader reader,
                                      int rawDocLengths[],
                                      int rawDocLengths2[])
        throws IOException {
  final int maxDoc = reader.maxDoc();
  final Bits liveDocs = reader.getLiveDocs();
  int totalNumDocs = 0;
  if (matchingVectorsReader != null) {
    // We can bulk-copy because the fieldInfos are "congruent"
    for (int docNum = 0; docNum < maxDoc;) {
      if (!liveDocs.get(docNum)) {
        // skip deleted docs
        ++docNum;
        continue;
      }
      // We can optimize this case (doing a bulk byte copy) since the field
      // numbers are identical
      int start = docNum, numDocs = 0;
      do {
        docNum++;
        numDocs++;
        if (docNum >= maxDoc) break;
        if (!liveDocs.get(docNum)) {
          docNum++;
          break;
        }
      } while(numDocs < MAX_RAW_MERGE_DOCS);
      
      matchingVectorsReader.rawDocs(rawDocLengths, rawDocLengths2, start, numDocs);
      addRawDocuments(matchingVectorsReader, rawDocLengths, rawDocLengths2, numDocs);
      totalNumDocs += numDocs;
      mergeState.checkAbort.work(300 * numDocs);
    }
  } else {
    for (int docNum = 0; docNum < maxDoc; docNum++) {
      if (!liveDocs.get(docNum)) {
        // skip deleted docs
        continue;
      }
      
      // NOTE: it's very important to first assign to vectors then pass it to
      // termVectorsWriter.addAllDocVectors; see LUCENE-1282
      Fields vectors = reader.getTermVectors(docNum);
      addAllDocVectors(vectors, mergeState);
      totalNumDocs++;
      mergeState.checkAbort.work(300);
    }
  }
  return totalNumDocs;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:53,代码来源:Lucene40TermVectorsWriter.java


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