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

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

java 1次浏览

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

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

示例1: estimateStringFieldData

点赞 3

import org.apache.lucene.codecs.blocktree.FieldReader; //导入依赖的package包/类
/**
 * @return the estimate for loading the entire term set into field data, or 0 if unavailable
 */
public long estimateStringFieldData() {
    try {
        LeafReader reader = context.reader();
        Terms terms = reader.terms(getFieldName());

        Fields fields = reader.fields();
        final Terms fieldTerms = fields.terms(getFieldName());

        if (fieldTerms instanceof FieldReader) {
            final Stats stats = ((FieldReader) fieldTerms).getStats();
            long totalTermBytes = stats.totalTermBytes;
            if (logger.isTraceEnabled()) {
                logger.trace("totalTermBytes: {}, terms.size(): {}, terms.getSumDocFreq(): {}",
                        totalTermBytes, terms.size(), terms.getSumDocFreq());
            }
            long totalBytes = totalTermBytes + (2 * terms.size()) + (4 * terms.getSumDocFreq());
            return totalBytes;
        }
    } catch (Exception e) {
        logger.warn("Unable to estimate memory overhead", e);
    }
    return 0;
}
 

开发者ID:justor,
项目名称:elasticsearch_my,
代码行数:27,
代码来源:PagedBytesIndexFieldData.java

示例2: estimateStringFieldData

点赞 3

import org.apache.lucene.codecs.blocktree.FieldReader; //导入依赖的package包/类
/**
 * @return the estimate for loading the entire term set into field data, or 0 if unavailable
 */
public long estimateStringFieldData() {
    try {
        LeafReader reader = context.reader();
        Terms terms = reader.terms(getFieldNames().indexName());

        Fields fields = reader.fields();
        final Terms fieldTerms = fields.terms(getFieldNames().indexName());

        if (fieldTerms instanceof FieldReader) {
            final Stats stats = ((FieldReader) fieldTerms).getStats();
            long totalTermBytes = stats.totalTermBytes;
            if (logger.isTraceEnabled()) {
                logger.trace("totalTermBytes: {}, terms.size(): {}, terms.getSumDocFreq(): {}",
                        totalTermBytes, terms.size(), terms.getSumDocFreq());
            }
            long totalBytes = totalTermBytes + (2 * terms.size()) + (4 * terms.getSumDocFreq());
            return totalBytes;
        }
    } catch (Exception e) {
        logger.warn("Unable to estimate memory overhead", e);
    }
    return 0;
}
 

开发者ID:baidu,
项目名称:Elasticsearch,
代码行数:27,
代码来源:PagedBytesIndexFieldData.java

示例3: testFinalBlock

点赞 3

import org.apache.lucene.codecs.blocktree.FieldReader; //导入依赖的package包/类
/** Make sure the final sub-block(s) are not skipped. */
public void testFinalBlock() throws Exception {
  Directory d = newDirectory();
  IndexWriter w = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));
  for(int i=0;i<25;i++) {
    Document doc = new Document();
    doc.add(newStringField("field", Character.toString((char) (97+i)), Field.Store.NO));
    doc.add(newStringField("field", "z" + Character.toString((char) (97+i)), Field.Store.NO));
    w.addDocument(doc);
  }
  w.forceMerge(1);

  DirectoryReader r = DirectoryReader.open(w, true);
  assertEquals(1, r.leaves().size());
  FieldReader field = (FieldReader) r.leaves().get(0).reader().fields().terms("field");
  // We should see exactly two blocks: one root block (prefix empty string) and one block for z* terms (prefix z):
  Stats stats = field.computeStats();
  assertEquals(0, stats.floorBlockCount);
  assertEquals(2, stats.nonFloorBlockCount);
  r.close();
  w.close();
  d.close();
}
 

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


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