• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TermVectorsReader类的典型用法和代码示例

java 1次浏览

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

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

示例1: clone

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public TermVectorsReader clone() {
  IndexInput cloneTvx = null;
  IndexInput cloneTvd = null;
  IndexInput cloneTvf = null;

  // These are null when a TermVectorsReader was created
  // on a segment that did not have term vectors saved
  if (tvx != null && tvd != null && tvf != null) {
    cloneTvx = tvx.clone();
    cloneTvd = tvd.clone();
    cloneTvf = tvf.clone();
  }
  
  return new Lucene40TermVectorsReader(fieldInfos, cloneTvx, cloneTvd, cloneTvf, size, numTotalDocs);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:17,
代码来源:Lucene40TermVectorsReader.java

示例2: clone

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public TermVectorsReader clone() {
  IndexInput cloneTvx = null;
  IndexInput cloneTvd = null;
  IndexInput cloneTvf = null;

  // These are null when a TermVectorsReader was created
  // on a segment that did not have term vectors saved
  if (tvx != null && tvd != null && tvf != null) {
    cloneTvx = tvx.clone();
    cloneTvd = tvd.clone();
    cloneTvf = tvf.clone();
  }
  
  return new Lucene3xTermVectorsReader(fieldInfos, cloneTvx, cloneTvd, cloneTvf, size, numTotalDocs, docStoreOffset, format);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:17,
代码来源:Lucene3xTermVectorsReader.java

示例3: vectorsReader

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public TermVectorsReader vectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context) throws IOException {
  return new Lucene3xTermVectorsReader(directory, segmentInfo, fieldInfos, context) {
    @Override
    protected boolean sortTermsByUnicode() {
      // We carefully peek into stack track above us: if
      // we are part of a "merge", we must sort by UTF16:
      boolean unicodeSortOrder = true;

      StackTraceElement[] trace = new Exception().getStackTrace();
      for (int i = 0; i < trace.length; i++) {
        //System.out.println(trace[i].getClassName());
        if ("merge".equals(trace[i].getMethodName())) {
          unicodeSortOrder = false;
          if (LuceneTestCase.VERBOSE) {
            System.out.println("NOTE: PreFlexRW codec: forcing legacy UTF16 vector term sort order");
          }
          break;
        }
      }

      return unicodeSortOrder;
    }
  };
}
 

开发者ID:europeana,
项目名称:search,
代码行数:26,
代码来源:PreFlexRWTermVectorsFormat.java

示例4: testReader

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
public void testReader() throws IOException {
  TermVectorsReader reader = Codec.getDefault().termVectorsFormat().vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
  for (int j = 0; j < 5; j++) {
    Terms vector = reader.get(j).terms(testFields[0]);
    assertNotNull(vector);
    assertEquals(testTerms.length, vector.size());
    TermsEnum termsEnum = vector.iterator(null);
    for (int i = 0; i < testTerms.length; i++) {
      final BytesRef text = termsEnum.next();
      assertNotNull(text);
      String term = text.utf8ToString();
      //System.out.println("Term: " + term);
      assertEquals(testTerms[i], term);
    }
    assertNull(termsEnum.next());
  }
  reader.close();
}
 

开发者ID:europeana,
项目名称:search,
代码行数:19,
代码来源:TestTermVectorsReader.java

示例5: testDocsEnum

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
public void testDocsEnum() throws IOException {
  TermVectorsReader reader = Codec.getDefault().termVectorsFormat().vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
  for (int j = 0; j < 5; j++) {
    Terms vector = reader.get(j).terms(testFields[0]);
    assertNotNull(vector);
    assertEquals(testTerms.length, vector.size());
    TermsEnum termsEnum = vector.iterator(null);
    DocsEnum docsEnum = null;
    for (int i = 0; i < testTerms.length; i++) {
      final BytesRef text = termsEnum.next();
      assertNotNull(text);
      String term = text.utf8ToString();
      //System.out.println("Term: " + term);
      assertEquals(testTerms[i], term);
      
      docsEnum = TestUtil.docs(random(), termsEnum, null, docsEnum, DocsEnum.FLAG_NONE);
      assertNotNull(docsEnum);
      int doc = docsEnum.docID();
      assertEquals(-1, doc);
      assertTrue(docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
      assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
    }
    assertNull(termsEnum.next());
  }
  reader.close();
}
 

开发者ID:europeana,
项目名称:search,
代码行数:27,
代码来源:TestTermVectorsReader.java

示例6: testDocsEnum

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
public void testDocsEnum() throws IOException {
  TermVectorsReader reader = Codec.getDefault().termVectorsFormat().vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
  for (int j = 0; j < 5; j++) {
    Terms vector = reader.get(j).terms(testFields[0]);
    assertNotNull(vector);
    assertEquals(testTerms.length, vector.size());
    TermsEnum termsEnum = vector.iterator(null);
    DocsEnum docsEnum = null;
    for (int i = 0; i < testTerms.length; i++) {
      final BytesRef text = termsEnum.next();
      assertNotNull(text);
      String term = text.utf8ToString();
      //System.out.println("Term: " + term);
      assertEquals(testTerms[i], term);
      
      docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, DocsEnum.FLAG_NONE);
      assertNotNull(docsEnum);
      int doc = docsEnum.docID();
      assertTrue(doc == -1 || doc == DocIdSetIterator.NO_MORE_DOCS);
      assertTrue(docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
      assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
    }
    assertNull(termsEnum.next());
  }
  reader.close();
}
 

开发者ID:pkarmstr,
项目名称:NYBC,
代码行数:27,
代码来源:TestTermVectorsReader.java

示例7: testDocsEnum

点赞 3

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
public void testDocsEnum() throws IOException {
  TermVectorsReader reader = Codec.getDefault().termVectorsFormat().vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
  for (int j = 0; j < 5; j++) {
    Terms vector = reader.get(j).terms(testFields[0]);
    assertNotNull(vector);
    assertEquals(testTerms.length, vector.size());
    TermsEnum termsEnum = vector.iterator(null);
    DocsEnum docsEnum = null;
    for (int i = 0; i < testTerms.length; i++) {
      final BytesRef text = termsEnum.next();
      assertNotNull(text);
      String term = text.utf8ToString();
      //System.out.println("Term: " + term);
      assertEquals(testTerms[i], term);
      
      docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, DocsEnum.FLAG_NONE);
      assertNotNull(docsEnum);
      int doc = docsEnum.docID();
      assertEquals(-1, doc);
      assertTrue(docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
      assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
    }
    assertNull(termsEnum.next());
  }
  reader.close();
}
 

开发者ID:jimaguere,
项目名称:Maskana-Gestor-de-Conocimiento,
代码行数:27,
代码来源:TestTermVectorsReader.java

示例8: merge

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public final int merge(MergeState mergeState) throws IOException {
  // Used for bulk-reading raw bytes for term vectors
  int rawDocLengths[] = new int[MAX_RAW_MERGE_DOCS];
  int rawDocLengths2[] = new int[MAX_RAW_MERGE_DOCS];

  int idx = 0;
  int numDocs = 0;
  for (int i = 0; i < mergeState.readers.size(); i++) {
    final AtomicReader reader = mergeState.readers.get(i);

    final SegmentReader matchingSegmentReader = mergeState.matchingSegmentReaders[idx++];
    Lucene40TermVectorsReader matchingVectorsReader = null;
    if (matchingSegmentReader != null) {
      TermVectorsReader vectorsReader = matchingSegmentReader.getTermVectorsReader();

      if (vectorsReader != null && vectorsReader instanceof Lucene40TermVectorsReader) {
          matchingVectorsReader = (Lucene40TermVectorsReader) vectorsReader;
      }
    }
    if (reader.getLiveDocs() != null) {
      numDocs += copyVectorsWithDeletions(mergeState, matchingVectorsReader, reader, rawDocLengths, rawDocLengths2);
    } else {
      numDocs += copyVectorsNoDeletions(mergeState, matchingVectorsReader, reader, rawDocLengths, rawDocLengths2);
    }
  }
  finish(mergeState.fieldInfos, numDocs);
  return numDocs;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:30,
代码来源:Lucene40TermVectorsWriter.java

示例9: vectorsReader

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public final TermVectorsReader vectorsReader(Directory directory,
    SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context)
    throws IOException {
  return new CompressingTermVectorsReader(directory, segmentInfo, segmentSuffix,
      fieldInfos, context, formatName, compressionMode);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:8,
代码来源:CompressingTermVectorsFormat.java

示例10: vectorsReader

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public TermVectorsReader vectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(Lucene3xSegmentInfoFormat.getDocStoreSegment(segmentInfo), "", Lucene3xTermVectorsReader.VECTORS_FIELDS_EXTENSION);

  // Unfortunately, for 3.x indices, each segment's
  // FieldInfos can lie about hasVectors (claim it's true
  // when really it's false).... so we have to carefully
  // check if the files really exist before trying to open
  // them (4.x has fixed this):
  final boolean exists;
  if (Lucene3xSegmentInfoFormat.getDocStoreOffset(segmentInfo) != -1 && Lucene3xSegmentInfoFormat.getDocStoreIsCompoundFile(segmentInfo)) {
    String cfxFileName = IndexFileNames.segmentFileName(Lucene3xSegmentInfoFormat.getDocStoreSegment(segmentInfo), "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION);
    if (segmentInfo.dir.fileExists(cfxFileName)) {
      Directory cfsDir = new CompoundFileDirectory(segmentInfo.dir, cfxFileName, context, false);
      try {
        exists = cfsDir.fileExists(fileName);
      } finally {
        cfsDir.close();
      }
    } else {
      exists = false;
    }
  } else {
    exists = directory.fileExists(fileName);
  }

  if (!exists) {
    // 3x's FieldInfos sometimes lies and claims a segment
    // has vectors when it doesn't:
    return null;
  } else {
    return new Lucene3xTermVectorsReader(directory, segmentInfo, fieldInfos, context);
  }
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:35,
代码来源:Lucene3xTermVectorsFormat.java

示例11: getTermVectors

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public Fields getTermVectors(int docID) throws IOException {
  TermVectorsReader termVectorsReader = getTermVectorsReader();
  if (termVectorsReader == null) {
    return null;
  }
  checkBounds(docID);
  return termVectorsReader.get(docID);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:10,
代码来源:SegmentReader.java

示例12: checkIntegrity

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public void checkIntegrity() throws IOException {
  ensureOpen();
  
  // stored fields
  getFieldsReader().checkIntegrity();
  
  // term vectors
  TermVectorsReader termVectorsReader = getTermVectorsReader();
  if (termVectorsReader != null) {
    termVectorsReader.checkIntegrity();
  }
  
  // terms/postings
  if (core.fields != null) {
    core.fields.checkIntegrity();
  }
  
  // norms
  if (core.normsProducer != null) {
    core.normsProducer.checkIntegrity();
  }
  
  // docvalues
  if (dvProducers != null) {
    for (DocValuesProducer producer : dvProducers) {
      producer.checkIntegrity();
    }
  }
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:31,
代码来源:SegmentReader.java

示例13: clone

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
@Override
public TermVectorsReader clone() {
  if (in == null) {
    throw new AlreadyClosedException("this TermVectorsReader is closed");
  }
  return new SimpleTextTermVectorsReader(offsets, in.clone());
}
 

开发者ID:europeana,
项目名称:search,
代码行数:8,
代码来源:SimpleTextTermVectorsReader.java

示例14: testOffsetReader

点赞 2

import org.apache.lucene.codecs.TermVectorsReader; //导入依赖的package包/类
public void testOffsetReader() throws IOException {
  TermVectorsReader reader = Codec.getDefault().termVectorsFormat().vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
  Terms vector = reader.get(0).terms(testFields[0]);
  assertNotNull(vector);
  TermsEnum termsEnum = vector.iterator(null);
  assertNotNull(termsEnum);
  assertEquals(testTerms.length, vector.size());
  DocsAndPositionsEnum dpEnum = null;
  for (int i = 0; i < testTerms.length; i++) {
    final BytesRef text = termsEnum.next();
    assertNotNull(text);
    String term = text.utf8ToString();
    assertEquals(testTerms[i], term);

    dpEnum = termsEnum.docsAndPositions(null, dpEnum);
    assertNotNull(dpEnum);
    assertTrue(dpEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals(dpEnum.freq(), positions[i].length);
    for (int j = 0; j < positions[i].length; j++) {
      assertEquals(positions[i][j], dpEnum.nextPosition());
    }
    assertEquals(DocIdSetIterator.NO_MORE_DOCS, dpEnum.nextDoc());

    dpEnum = termsEnum.docsAndPositions(null, dpEnum);
    assertTrue(dpEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
    assertNotNull(dpEnum);
    assertEquals(dpEnum.freq(), positions[i].length);
    for (int j = 0; j < positions[i].length; j++) {
      assertEquals(positions[i][j], dpEnum.nextPosition());
      assertEquals(j*10, dpEnum.startOffset());
      assertEquals(j*10 + testTerms[i].length(), dpEnum.endOffset());
    }
    assertEquals(DocIdSetIterator.NO_MORE_DOCS, dpEnum.nextDoc());
  }
  reader.close();
}
 

开发者ID:europeana,
项目名称:search,
代码行数:37,
代码来源:TestTermVectorsReader.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)