當前位置: 首頁>>代碼示例>>Java>>正文


Java Bytes類代碼示例

本文整理匯總了Java中org.apache.lucene.search.FieldCache.Bytes的典型用法代碼示例。如果您正苦於以下問題:Java Bytes類的具體用法?Java Bytes怎麽用?Java Bytes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Bytes類屬於org.apache.lucene.search.FieldCache包,在下文中一共展示了Bytes類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testNonexistantFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonexistantFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  BytesRef scratch = binaries.get(0);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  scratch = sorted.get(0);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:54,代碼來源:TestFieldCache.java

示例2: testNonIndexedFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonIndexedFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new StoredField("bogusbytes", "bogus"));
  doc.add(new StoredField("bogusshorts", "bogus"));
  doc.add(new StoredField("bogusints", "bogus"));
  doc.add(new StoredField("boguslongs", "bogus"));
  doc.add(new StoredField("bogusfloats", "bogus"));
  doc.add(new StoredField("bogusdoubles", "bogus"));
  doc.add(new StoredField("bogusterms", "bogus"));
  doc.add(new StoredField("bogustermsindex", "bogus"));
  doc.add(new StoredField("bogusmultivalued", "bogus"));
  doc.add(new StoredField("bogusbits", "bogus"));
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  BytesRef scratch = binaries.get(0);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  scratch = sorted.get(0);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:64,代碼來源:TestFieldCache.java

示例3: testNonexistantFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonexistantFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BytesRef scratch = new BytesRef();
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms");
  binaries.get(0, scratch);
  assertTrue(scratch.bytes == BinaryDocValues.MISSING);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  sorted.get(0, scratch);
  assertTrue(scratch.bytes == BinaryDocValues.MISSING);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:55,代碼來源:TestFieldCache.java

示例4: testNonIndexedFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonIndexedFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new StoredField("bogusbytes", "bogus"));
  doc.add(new StoredField("bogusshorts", "bogus"));
  doc.add(new StoredField("bogusints", "bogus"));
  doc.add(new StoredField("boguslongs", "bogus"));
  doc.add(new StoredField("bogusfloats", "bogus"));
  doc.add(new StoredField("bogusdoubles", "bogus"));
  doc.add(new StoredField("bogusterms", "bogus"));
  doc.add(new StoredField("bogustermsindex", "bogus"));
  doc.add(new StoredField("bogusmultivalued", "bogus"));
  doc.add(new StoredField("bogusbits", "bogus"));
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BytesRef scratch = new BytesRef();
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms");
  binaries.get(0, scratch);
  assertTrue(scratch.bytes == BinaryDocValues.MISSING);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  sorted.get(0, scratch);
  assertTrue(scratch.bytes == BinaryDocValues.MISSING);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:65,代碼來源:TestFieldCache.java

示例5: testNonexistantFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonexistantFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BytesRef scratch = new BytesRef();
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  binaries.get(0, scratch);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  sorted.get(0, scratch);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:jimaguere,項目名稱:Maskana-Gestor-de-Conocimiento,代碼行數:55,代碼來源:TestFieldCache.java

示例6: testNonIndexedFields

import org.apache.lucene.search.FieldCache.Bytes; //導入依賴的package包/類
public void testNonIndexedFields() throws Exception {
  Directory dir = newDirectory();
  RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
  Document doc = new Document();
  doc.add(new StoredField("bogusbytes", "bogus"));
  doc.add(new StoredField("bogusshorts", "bogus"));
  doc.add(new StoredField("bogusints", "bogus"));
  doc.add(new StoredField("boguslongs", "bogus"));
  doc.add(new StoredField("bogusfloats", "bogus"));
  doc.add(new StoredField("bogusdoubles", "bogus"));
  doc.add(new StoredField("bogusterms", "bogus"));
  doc.add(new StoredField("bogustermsindex", "bogus"));
  doc.add(new StoredField("bogusmultivalued", "bogus"));
  doc.add(new StoredField("bogusbits", "bogus"));
  iw.addDocument(doc);
  DirectoryReader ir = iw.getReader();
  iw.close();
  
  AtomicReader ar = getOnlySegmentReader(ir);
  
  final FieldCache cache = FieldCache.DEFAULT;
  cache.purgeAllCaches();
  assertEquals(0, cache.getCacheEntries().length);
  
  Bytes bytes = cache.getBytes(ar, "bogusbytes", true);
  assertEquals(0, bytes.get(0));

  Shorts shorts = cache.getShorts(ar, "bogusshorts", true);
  assertEquals(0, shorts.get(0));
  
  Ints ints = cache.getInts(ar, "bogusints", true);
  assertEquals(0, ints.get(0));
  
  Longs longs = cache.getLongs(ar, "boguslongs", true);
  assertEquals(0, longs.get(0));
  
  Floats floats = cache.getFloats(ar, "bogusfloats", true);
  assertEquals(0, floats.get(0), 0.0f);
  
  Doubles doubles = cache.getDoubles(ar, "bogusdoubles", true);
  assertEquals(0, doubles.get(0), 0.0D);
  
  BytesRef scratch = new BytesRef();
  BinaryDocValues binaries = cache.getTerms(ar, "bogusterms", true);
  binaries.get(0, scratch);
  assertEquals(0, scratch.length);
  
  SortedDocValues sorted = cache.getTermsIndex(ar, "bogustermsindex");
  assertEquals(-1, sorted.getOrd(0));
  sorted.get(0, scratch);
  assertEquals(0, scratch.length);
  
  SortedSetDocValues sortedSet = cache.getDocTermOrds(ar, "bogusmultivalued");
  sortedSet.setDocument(0);
  assertEquals(SortedSetDocValues.NO_MORE_ORDS, sortedSet.nextOrd());
  
  Bits bits = cache.getDocsWithField(ar, "bogusbits");
  assertFalse(bits.get(0));
  
  // check that we cached nothing
  assertEquals(0, cache.getCacheEntries().length);
  ir.close();
  dir.close();
}
 
開發者ID:jimaguere,項目名稱:Maskana-Gestor-de-Conocimiento,代碼行數:65,代碼來源:TestFieldCache.java


注:本文中的org.apache.lucene.search.FieldCache.Bytes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。