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


Java SerialMergeScheduler类代码示例

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


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

示例1: makeDeltaIndexWriter

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的package包/类
/**
 * Make a lucene index writer
 * 
 * @param location File
 * @param analyzer Analyzer
 * @return IndexWriter
 * @throws IOException
 */
private IndexWriter makeDeltaIndexWriter(File location, Analyzer analyzer) throws IOException
{
    IndexWriter writer;
    if (!IndexReader.indexExists(location))
    {
        writer = new IndexWriter(location, analyzer, true, MaxFieldLength.LIMITED);
    }
    else
    {
        writer = new IndexWriter(location, analyzer, false, MaxFieldLength.LIMITED);
    }
    writer.setUseCompoundFile(writerUseCompoundFile);
    writer.setMaxBufferedDocs(writerMaxBufferedDocs);
    writer.setRAMBufferSizeMB(writerRamBufferSizeMb);
    writer.setMergeFactor(writerMergeFactor);
    writer.setMaxMergeDocs(writerMaxMergeDocs);
    writer.setWriteLockTimeout(writeLockTimeout);
    writer.setMaxFieldLength(maxFieldLength);
    writer.setTermIndexInterval(termIndexInterval);
    writer.setMergeScheduler(new SerialMergeScheduler());
    writer.setMergePolicy(new LogDocMergePolicy());
    return writer;

}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:33,代码来源:IndexInfo.java

示例2: open

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的package包/类
private IndexWriter open(boolean create) throws IOException, SearchLibException {
	indexWriterLock.lock();
	final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, null);
	config.setOpenMode(create ? OpenMode.CREATE_OR_APPEND : OpenMode.APPEND);
	config.setMergeScheduler(new SerialMergeScheduler());
	config.setWriteLockTimeout(indexConfig.getWriteLockTimeout());
	config.setRAMBufferSizeMB(128);
	final Similarity similarity = indexConfig.getNewSimilarityInstance();
	if (similarity != null)
		config.setSimilarity(similarity);
	if (!create) {
		final SnapshotDeletionPolicy snapshotDeletionPolicy =
				new SnapshotDeletionPolicy(config.getIndexDeletionPolicy());
		config.setIndexDeletionPolicy(snapshotDeletionPolicy);
	}
	Logging.debug("WriteLocal open " + indexDirectory.getDirectory());
	return new IndexWriter(indexDirectory.getDirectory(), config);
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:19,代码来源:WriterLocal.java

示例3: createRandomIndex

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的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

示例4: getIndexWriterConfig

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的package包/类
/**
 * Method that return {@link IndexWriterConfig} properly configured in order to 
 * work in google app engine environment.
 * @param analyzer The analyzer to use
 * @return An {@link IndexWriterConfig} properly configured
 */
@SuppressWarnings("resource")//SerialMergeSceduler is Closable
public static IndexWriterConfig getIndexWriterConfig(Analyzer analyzer) {
	final IndexWriterConfig config = new IndexWriterConfig(analyzer);
	config.setMergeScheduler(new SerialMergeScheduler());
	return config;
}
 
开发者ID:UltimaPhoenix,项目名称:luceneappengine,代码行数:13,代码来源:GaeLuceneUtil.java

示例5: newIndexWriterConfig

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的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

示例6: createIndexWriterConfig

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的package包/类
protected void createIndexWriterConfig() {
    indexConfig = new IndexWriterConfig(LUCENE_VERSION, analyzer);
    indexConfig.setMergeScheduler(new SerialMergeScheduler());
    indexConfig.setMaxThreadStates(1);
}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:6,代码来源:ExodusLuceneTestsBase.java

示例7: testMulipleCommitsAndReopens

import org.apache.lucene.index.SerialMergeScheduler; //导入依赖的package包/类
@Test
public void testMulipleCommitsAndReopens() throws IOException {
  IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_43, new KeywordAnalyzer());
  conf.setMergeScheduler(new SerialMergeScheduler());
  TieredMergePolicy mergePolicy = (TieredMergePolicy) conf.getMergePolicy();
  mergePolicy.setUseCompoundFile(false);

  Set<String> fileSet = new TreeSet<String>();
  long seed = new Random().nextLong();
  System.out.println("Seed:" + seed);
  Random random = new Random(seed);
  int docCount = 0;
  int passes = 10;
  byte[] segmentsGenContents = null;
  for (int run = 0; run < passes; run++) {
    final FastHdfsKeyValueDirectory directory = new FastHdfsKeyValueDirectory(false, _timer, _configuration,
        new Path(_path, "test_multiple_commits_reopens"));
    if (segmentsGenContents != null) {
      byte[] segmentsGenContentsCurrent = readSegmentsGen(directory);
      assertTrue(Arrays.equals(segmentsGenContents, segmentsGenContentsCurrent));
    }
    assertFiles(fileSet, run, -1, directory);
    assertEquals(docCount, getDocumentCount(directory));
    IndexWriter writer = new IndexWriter(directory, conf.clone());
    int numberOfCommits = random.nextInt(100);
    for (int i = 0; i < numberOfCommits; i++) {
      assertFiles(fileSet, run, i, directory);
      addDocuments(writer, random.nextInt(100));
      // Before Commit
      writer.commit();
      // After Commit

      // Set files after commit
      {
        fileSet.clear();
        List<IndexCommit> listCommits = DirectoryReader.listCommits(directory);
        assertEquals(1, listCommits.size());
        IndexCommit indexCommit = listCommits.get(0);
        fileSet.addAll(indexCommit.getFileNames());
      }
      segmentsGenContents = readSegmentsGen(directory);
    }
    docCount = getDocumentCount(directory);
  }
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:46,代码来源:FastHdfsKeyValueDirectoryTest.java


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