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


Java Codec.setDefault方法代码示例

本文整理汇总了Java中org.apache.lucene.codecs.Codec.setDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Codec.setDefault方法的具体用法?Java Codec.setDefault怎么用?Java Codec.setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.codecs.Codec的用法示例。


在下文中一共展示了Codec.setDefault方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: after

import org.apache.lucene.codecs.Codec; //导入方法依赖的package包/类
/**
 * After suite cleanup (always invoked).
 */
@Override
protected void after() throws Exception {
  for (Map.Entry<String,String> e : restoreProperties.entrySet()) {
    if (e.getValue() == null) {
      System.clearProperty(e.getKey());
    } else {
      System.setProperty(e.getKey(), e.getValue());
    }
  }
  restoreProperties.clear();

  Codec.setDefault(savedCodec);
  InfoStream.setDefault(savedInfoStream);
  if (savedLocale != null) Locale.setDefault(savedLocale);
  if (savedTimeZone != null) TimeZone.setDefault(savedTimeZone);
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestRuleSetupAndRestoreClassEnv.java

示例2: beforeClass

import org.apache.lucene.codecs.Codec; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
  savedCodec = Codec.getDefault();
  // currently only these codecs that support random access ordinals
  int victim = random().nextInt(2);
  switch(victim) {
    case 0:  Codec.setDefault(TestUtil.alwaysDocValuesFormat(new DirectDocValuesFormat()));
    default: Codec.setDefault(TestUtil.alwaysDocValuesFormat(new Lucene410DocValuesFormat()));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestSortedSetSortFieldSelectors.java

示例3: afterClass

import org.apache.lucene.codecs.Codec; //导入方法依赖的package包/类
@AfterClass
public static void afterClass() throws Exception {
  Codec.setDefault(savedCodec);
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:TestSortedSetSortFieldSelectors.java

示例4: setUp

import org.apache.lucene.codecs.Codec; //导入方法依赖的package包/类
public void setUp() throws Exception {
  super.setUp();
  // set the default codec, so adding test cases to this isn't fragile
  savedCodec = Codec.getDefault();
  Codec.setDefault(getCodec());
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:BaseIndexFileFormatTestCase.java

示例5: tearDown

import org.apache.lucene.codecs.Codec; //导入方法依赖的package包/类
public void tearDown() throws Exception {
  Codec.setDefault(savedCodec); // restore
  super.tearDown();
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:BaseIndexFileFormatTestCase.java

示例6: testRamBytesUsed

import org.apache.lucene.codecs.Codec; //导入方法依赖的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


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