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


Java MockRandomPostingsFormat類代碼示例

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


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

示例1: RandomCodec

import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
  this.perFieldSeed = random.nextInt();
  this.avoidCodecs = avoidCodecs;
  // TODO: make it possible to specify min/max iterms per
  // block via CL:
  int minItemsPerBlock = TestUtil.nextInt(random, 2, 100);
  int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
  int lowFreqCutoff = TestUtil.nextInt(random, 2, 100);

  add(avoidCodecs,
      new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
      new FSTPostingsFormat(),
      new FSTOrdPostingsFormat(),
      new FSTPulsing41PostingsFormat(1 + random.nextInt(20)),
      new FSTOrdPulsing41PostingsFormat(1 + random.nextInt(20)),
      new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
                               LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      // add pulsing again with (usually) different parameters
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      //TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed 
      //with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing 
      //with such "wrapper" classes?
      new TestBloomFilteredLucene41Postings(),                
      new MockSepPostingsFormat(),
      new MockFixedIntBlockPostingsFormat(TestUtil.nextInt(random, 1, 2000)),
      new MockVariableIntBlockPostingsFormat( TestUtil.nextInt(random, 1, 127)),
      new MockRandomPostingsFormat(random),
      new NestedPulsingPostingsFormat(),
      new Lucene41WithOrds(),
      new SimpleTextPostingsFormat(),
      new AssertingPostingsFormat(),
      new MemoryPostingsFormat(true, random.nextFloat()),
      new MemoryPostingsFormat(false, random.nextFloat()));
  
  addDocValues(avoidCodecs,
      new Lucene410DocValuesFormat(),
      new MemoryDocValuesFormat(),
      new SimpleTextDocValuesFormat(),
      new AssertingDocValuesFormat());

  Collections.shuffle(formats, random);
  Collections.shuffle(dvFormats, random);

  // Avoid too many open files:
  if (formats.size() > 4) {
    formats = formats.subList(0, 4);
  }
  if (dvFormats.size() > 4) {
    dvFormats = dvFormats.subList(0, 4);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:53,代碼來源:RandomCodec.java

示例2: testRamBytesUsed

import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; //導入依賴的package包/類
/** Test the accuracy of the ramBytesUsed estimations. */
public void testRamBytesUsed() throws IOException {
  if (Codec.getDefault() instanceof RandomCodec) {
    // this test relies on the fact that two segments will be written with
    // the same codec so we need to disable MockRandomPF
    final Set<String> avoidCodecs = new HashSet<>(((RandomCodec) Codec.getDefault()).avoidCodecs);
    avoidCodecs.add(new MockRandomPostingsFormat().getName());
    Codec.setDefault(new RandomCodec(random(), avoidCodecs));
  }
  Directory dir = newDirectory();
  IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
  IndexWriter w = new IndexWriter(dir, cfg);
  // we need to index enough documents so that constant overhead doesn't dominate
  final int numDocs = atLeast(10000);
  AtomicReader reader1 = null;
  for (int i = 0; i < numDocs; ++i) {
    Document d = new Document();
    addRandomFields(d);
    w.addDocument(d);
    if (i == 100) {
      w.forceMerge(1);
      w.commit();
      reader1 = getOnlySegmentReader(DirectoryReader.open(dir));
    }
  }
  w.forceMerge(1);
  w.commit();
  w.close();

  AtomicReader reader2 = getOnlySegmentReader(DirectoryReader.open(dir));

  for (AtomicReader reader : Arrays.asList(reader1, reader2)) {
    new SimpleMergedSegmentWarmer(InfoStream.NO_OUTPUT).warm(reader);
  }

  final long actualBytes = RamUsageTester.sizeOf(reader2, new Accumulator(reader2)) - RamUsageTester.sizeOf(reader1, new Accumulator(reader1));
  final long expectedBytes = ((SegmentReader) reader2).ramBytesUsed() - ((SegmentReader) reader1).ramBytesUsed();
  final long absoluteError = actualBytes - expectedBytes;
  final double relativeError = (double) absoluteError / actualBytes;
  final String message = "Actual RAM usage " + actualBytes + ", but got " + expectedBytes + ", " + 100*relativeError + "% error";
  assertTrue(message, Math.abs(relativeError) < 0.20d || Math.abs(absoluteError) < 1000);

  reader1.close();
  reader2.close();
  dir.close();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:47,代碼來源:BaseIndexFileFormatTestCase.java

示例3: RandomCodec

import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
  this.perFieldSeed = random.nextInt();
  // TODO: make it possible to specify min/max iterms per
  // block via CL:
  int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
  int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
  int lowFreqCutoff = _TestUtil.nextInt(random, 2, 100);

  add(avoidCodecs,
      new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
      new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
                               LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      // add pulsing again with (usually) different parameters
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      //TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed 
      //with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing 
      //with such "wrapper" classes?
      new TestBloomFilteredLucene41Postings(),                
      new MockSepPostingsFormat(),
      new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)),
      new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)),
      new MockRandomPostingsFormat(random),
      new NestedPulsingPostingsFormat(),
      new Lucene41WithOrds(),
      new SimpleTextPostingsFormat(),
      new AssertingPostingsFormat(),
      new MemoryPostingsFormat(true, random.nextFloat()),
      new MemoryPostingsFormat(false, random.nextFloat()));
  
  addDocValues(avoidCodecs,
      new Lucene42DocValuesFormat(),
      new DiskDocValuesFormat(),
      new SimpleTextDocValuesFormat(),
      new AssertingDocValuesFormat(),
      new CheapBastardDocValuesFormat());

  Collections.shuffle(formats, random);
  Collections.shuffle(dvFormats, random);

  // Avoid too many open files:
  if (formats.size() > 4) {
    formats = formats.subList(0, 4);
  }
  if (dvFormats.size() > 4) {
    dvFormats = dvFormats.subList(0, 4);
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:49,代碼來源:RandomCodec.java

示例4: RandomCodec

import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; //導入依賴的package包/類
public RandomCodec(Random random, Set<String> avoidCodecs) {
  this.perFieldSeed = random.nextInt();
  // TODO: make it possible to specify min/max iterms per
  // block via CL:
  int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
  int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
  int lowFreqCutoff = _TestUtil.nextInt(random, 2, 100);

  add(avoidCodecs,
      new Lucene41PostingsFormat(minItemsPerBlock, maxItemsPerBlock),
      new DirectPostingsFormat(LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : maxItemsPerBlock),
                               LuceneTestCase.rarely(random) ? 1 : (LuceneTestCase.rarely(random) ? Integer.MAX_VALUE : lowFreqCutoff)),
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      // add pulsing again with (usually) different parameters
      new Pulsing41PostingsFormat(1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock),
      //TODO as a PostingsFormat which wraps others, we should allow TestBloomFilteredLucene41Postings to be constructed 
      //with a choice of concrete PostingsFormats. Maybe useful to have a generic means of marking and dealing 
      //with such "wrapper" classes?
      new TestBloomFilteredLucene41Postings(),                
      new MockSepPostingsFormat(),
      new MockFixedIntBlockPostingsFormat(_TestUtil.nextInt(random, 1, 2000)),
      new MockVariableIntBlockPostingsFormat( _TestUtil.nextInt(random, 1, 127)),
      new MockRandomPostingsFormat(random),
      new NestedPulsingPostingsFormat(),
      new Lucene41WithOrds(),
      new SimpleTextPostingsFormat(),
      new AssertingPostingsFormat(),
      new MemoryPostingsFormat(true, random.nextFloat()),
      new MemoryPostingsFormat(false, random.nextFloat()));
  
  addDocValues(avoidCodecs,
      new Lucene45DocValuesFormat(),
      new DiskDocValuesFormat(),
      new MemoryDocValuesFormat(),
      new SimpleTextDocValuesFormat(),
      new AssertingDocValuesFormat());

  Collections.shuffle(formats, random);
  Collections.shuffle(dvFormats, random);

  // Avoid too many open files:
  if (formats.size() > 4) {
    formats = formats.subList(0, 4);
  }
  if (dvFormats.size() > 4) {
    dvFormats = dvFormats.subList(0, 4);
  }
}
 
開發者ID:jimaguere,項目名稱:Maskana-Gestor-de-Conocimiento,代碼行數:49,代碼來源:RandomCodec.java


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