當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。