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


Java IndexWriterConfig.setMergeScheduler方法代码示例

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


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

示例1: getIndexWriterConfig

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
private IndexWriterConfig getIndexWriterConfig(boolean create) {
    final IndexWriterConfig iwc = new IndexWriterConfig(engineConfig.getAnalyzer());
    iwc.setCommitOnClose(false); // we by default don't commit on close
    iwc.setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND);
    iwc.setIndexDeletionPolicy(deletionPolicy);
    // with tests.verbose, lucene sets this up: plumb to align with filesystem stream
    boolean verbose = false;
    try {
        verbose = Boolean.parseBoolean(System.getProperty("tests.verbose"));
    } catch (Exception ignore) {
    }
    iwc.setInfoStream(verbose ? InfoStream.getDefault() : new LoggerInfoStream(logger));
    iwc.setMergeScheduler(mergeScheduler);
    MergePolicy mergePolicy = config().getMergePolicy();
    // Give us the opportunity to upgrade old segments while performing
    // background merges
    mergePolicy = new ElasticsearchMergePolicy(mergePolicy);
    iwc.setMergePolicy(mergePolicy);
    iwc.setSimilarity(engineConfig.getSimilarity());
    iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().getMbFrac());
    iwc.setCodec(engineConfig.getCodec());
    iwc.setUseCompoundFile(true); // always use compound on flush - reduces # of file-handles on refresh
    return iwc;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:InternalEngine.java

示例2: testCustomMergeScheduler

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
public void testCustomMergeScheduler() throws Exception {
  // we don't really need to execute anything, just to make sure the custom MS
  // compiles. But ensure that it can be used as well, e.g., no other hidden
  // dependencies or something. Therefore, don't use any random API !
  Directory dir = new RAMDirectory();
  IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
  conf.setMergeScheduler(new ReportingMergeScheduler());
  IndexWriter writer = new IndexWriter(dir, conf);
  writer.addDocument(new Document());
  writer.commit(); // trigger flush
  writer.addDocument(new Document());
  writer.commit(); // trigger flush
  writer.forceMerge(1);
  writer.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:TestMergeSchedulerExternal.java

示例3: createIndexWriterConfig

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
public IndexWriterConfig createIndexWriterConfig() throws IOException {
  IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LATEST, getIndexAnalyzerInstance());
  indexWriterConfig.setRAMBufferSizeMB(48);

  MergePolicy mergePolicy = getPluginManager().getInstance(LindenConfigBuilder.MERGE_POLICY, MergePolicy.class);
  if (mergePolicy != null) {
    indexWriterConfig.setMergePolicy(mergePolicy);
  }
  LOGGER.info("Merge policy : {}", mergePolicy == null ? "Default" : mergePolicy);

  ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
  cms.setMaxMergesAndThreads(8, 1);
  indexWriterConfig.setMergeScheduler(cms);
  return indexWriterConfig;
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:16,代码来源:LindenConfig.java

示例4: initSearcher

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
@Before
public void initSearcher() throws IOException {
    dir = newDirectory();
    IndexWriterConfig indexWriterConfig = newIndexWriterConfig(new WhitespaceAnalyzer());
    indexWriterConfig.setMergeScheduler(NoMergeScheduler.INSTANCE);
    indexWriterConfig.setMergePolicy(NoMergePolicy.INSTANCE);
    w = new IndexWriter(dir, indexWriterConfig);
    Document d = new Document();
    d.add(new TextField(FIELD, "don't  be", Field.Store.YES));
    d.add(new TextField("_uid", "1", Field.Store.YES));
    w.addDocument(d);
    w.commit();
    d = new Document();
    d.add(new TextField(FIELD, "ever always forget  be", Field.Store.YES));
    d.add(new TextField("_uid", "2", Field.Store.YES));
    w.addDocument(d);
    w.commit();
    d = new Document();
    d.add(new TextField(FIELD, "careful careful", Field.Store.YES));
    d.add(new TextField("_uid", "3", Field.Store.YES));
    w.addDocument(d);
    w.commit();
    d = new Document();
    d.add(new TextField(FIELD, "ever always careful careful don't be forget be", Field.Store.YES));
    d.add(new TextField("_uid", "4", Field.Store.YES));
    w.addDocument(d);
    w.commit();
    reader = DirectoryReader.open(w, true, true);
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:30,代码来源:AllTermsTests.java

示例5: createRandomIndex

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
private void createRandomIndex() throws IOException {
  dir = newDirectory();
  numDocs = atLeast(150);
  final int numTerms = TestUtil.nextInt(random(), 1, numDocs / 5);
  Set<String> randomTerms = new HashSet<>();
  while (randomTerms.size() < numTerms) {
    randomTerms.add(TestUtil.randomSimpleString(random()));
  }
  terms = new ArrayList<>(randomTerms);
  final long seed = random().nextLong();
  final IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));
  iwc.setMergeScheduler(new SerialMergeScheduler()); // for reproducible tests
  iwc.setMergePolicy(TestSortingMergePolicy.newSortingMergePolicy(sort));
  iw = new RandomIndexWriter(new Random(seed), dir, iwc);
  iw.setDoRandomForceMerge(false); // don't do this, it may happen anyway with MockRandomMP
  for (int i = 0; i < numDocs; ++i) {
    final Document doc = randomDocument();
    iw.addDocument(doc);
    if (i == numDocs / 2 || (i != numDocs - 1 && random().nextInt(8) == 0)) {
      iw.commit();
    }
    if (random().nextInt(15) == 0) {
      final String term = RandomPicks.randomFrom(random(), terms);
      iw.deleteDocuments(new Term("s", term));
    }
  }
  if (random().nextBoolean()) {
    iw.forceMerge(5);
  }
  reader = iw.getReader();
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:TestEarlyTermination.java

示例6: newIndexWriterConfig

import org.apache.lucene.index.IndexWriterConfig; //导入方法依赖的package包/类
/** create a new index writer config with random defaults using the specified random */
public static IndexWriterConfig newIndexWriterConfig(Random r, Version v, Analyzer a) {
  IndexWriterConfig c = new IndexWriterConfig(v, a);
  c.setSimilarity(classEnvRule.similarity);
  if (VERBOSE) {
    // Even though TestRuleSetupAndRestoreClassEnv calls
    // InfoStream.setDefault, we do it again here so that
    // the PrintStreamInfoStream.messageID increments so
    // that when there are separate instances of
    // IndexWriter created we see "IW 0", "IW 1", "IW 2",
    // ... instead of just always "IW 0":
    c.setInfoStream(new TestRuleSetupAndRestoreClassEnv.ThreadNameFixingPrintStreamInfoStream(System.out));
  }

  if (r.nextBoolean()) {
    c.setMergeScheduler(new SerialMergeScheduler());
  } else if (rarely(r)) {
    int maxThreadCount = TestUtil.nextInt(r, 1, 4);
    int maxMergeCount = TestUtil.nextInt(r, maxThreadCount, maxThreadCount+4);
    ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
    cms.setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
    c.setMergeScheduler(cms);
  }
  if (r.nextBoolean()) {
    if (rarely(r)) {
      // crazy value
      c.setMaxBufferedDocs(TestUtil.nextInt(r, 2, 15));
    } else {
      // reasonable value
      c.setMaxBufferedDocs(TestUtil.nextInt(r, 16, 1000));
    }
  }
  if (r.nextBoolean()) {
    if (rarely(r)) {
      // crazy value
      c.setTermIndexInterval(r.nextBoolean() ? TestUtil.nextInt(r, 1, 31) : TestUtil.nextInt(r, 129, 1000));
    } else {
      // reasonable value
      c.setTermIndexInterval(TestUtil.nextInt(r, 32, 128));
    }
  }
  if (r.nextBoolean()) {
    int maxNumThreadStates = rarely(r) ? TestUtil.nextInt(r, 5, 20) // crazy value
        : TestUtil.nextInt(r, 1, 4); // reasonable value

    c.setMaxThreadStates(maxNumThreadStates);
  }

  c.setMergePolicy(newMergePolicy(r));

  if (rarely(r)) {
    c.setMergedSegmentWarmer(new SimpleMergedSegmentWarmer(c.getInfoStream()));
  }
  c.setUseCompoundFile(r.nextBoolean());
  c.setReaderPooling(r.nextBoolean());
  c.setReaderTermsIndexDivisor(TestUtil.nextInt(r, 1, 4));
  c.setCheckIntegrityAtMerge(r.nextBoolean());
  return c;
}
 
开发者ID:europeana,项目名称:search,代码行数:60,代码来源:LuceneTestCase.java


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