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


Java DirectReader类代码示例

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


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

示例1: testSimple

import org.apache.lucene.util.packed.DirectReader; //导入依赖的package包/类
/** simple encode/decode */
public void testSimple() throws Exception {
  Directory dir = newDirectory();
  int bitsPerValue = DirectWriter.bitsRequired(2);
  IndexOutput output = dir.createOutput("foo", IOContext.DEFAULT);
  DirectWriter writer = DirectWriter.getInstance(output, 5, bitsPerValue);
  writer.add(1);
  writer.add(0);
  writer.add(2);
  writer.add(1);
  writer.add(2);
  writer.finish();
  output.close();
  IndexInput input = dir.openInput("foo", IOContext.DEFAULT);
  NumericDocValues reader = DirectReader.getInstance(input.randomAccessSlice(0, input.length()), bitsPerValue);
  assertEquals(1, reader.get(0));
  assertEquals(0, reader.get(1));
  assertEquals(2, reader.get(2));
  assertEquals(1, reader.get(3));
  assertEquals(2, reader.get(4));
  input.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TestDirectPacked.java

示例2: doTestBpv

import org.apache.lucene.util.packed.DirectReader; //导入依赖的package包/类
private void doTestBpv(Directory directory, int bpv) throws Exception {
  MyRandom random = new MyRandom(random().nextLong());
  for (int i = 0; i < 100; i++) {
    long original[] = randomLongs(random, bpv);
    int bitsRequired = bpv == 64 ? 64 : DirectWriter.bitsRequired(1L<<(bpv-1));
    String name = "bpv" + bpv + "_" + i;
    IndexOutput output = directory.createOutput(name, IOContext.DEFAULT);
    DirectWriter writer = DirectWriter.getInstance(output, original.length, bitsRequired);
    for (int j = 0; j < original.length; j++) {
      writer.add(original[j]);
    }
    writer.finish();
    output.close();
    IndexInput input = directory.openInput(name, IOContext.DEFAULT);
    NumericDocValues reader = DirectReader.getInstance(input.randomAccessSlice(0, input.length()), bitsRequired);
    for (int j = 0; j < original.length; j++) {
      assertEquals("bpv=" + bpv, original[j], reader.get(j));
    }
    input.close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:TestDirectPacked.java


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