类org.apache.lucene.index.LogDocMergePolicy源码实例Demo

下面列出了怎么用org.apache.lucene.index.LogDocMergePolicy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lucene-solr   文件: TestPerFieldPostingsFormat2.java
private IndexWriter newWriter(Directory dir, IndexWriterConfig conf)
    throws IOException {
  LogDocMergePolicy logByteSizeMergePolicy = new LogDocMergePolicy();
  logByteSizeMergePolicy.setNoCFSRatio(0.0); // make sure we use plain
  // files
  conf.setMergePolicy(logByteSizeMergePolicy);

  final IndexWriter writer = new IndexWriter(dir, conf);
  return writer;
}
 
源代码2 项目: lucene-solr   文件: TestMergePolicyConfig.java
public void testLogMergePolicyFactoryConfig() throws Exception {

    final boolean byteSizeMP = random().nextBoolean();
    final Class<? extends LogMergePolicy> mpClass = byteSizeMP
        ? LogByteSizeMergePolicy.class : LogDocMergePolicy.class;
    final Class<? extends MergePolicyFactory> mpfClass = byteSizeMP
        ? LogByteSizeMergePolicyFactory.class : LogDocMergePolicyFactory.class;

    System.setProperty("solr.test.log.merge.policy.factory", mpfClass.getName());

    implTestLogMergePolicyConfig("solrconfig-logmergepolicyfactory.xml", mpClass);
  }
 
源代码3 项目: lucene-solr   文件: TestIndexMergeTool.java
public void testMergePolicyOption() throws Exception {
  Options options = Options.parse(new String[] { "-merge-policy", LogDocMergePolicy.class.getName(), "target", "source1", "source2" });
  assertEquals(LogDocMergePolicy.class, options.config.getMergePolicy().getClass());
}
 
源代码4 项目: lucene-solr   文件: LogDocMergePolicyFactory.java
@Override
protected MergePolicy getMergePolicyInstance() {
  return new LogDocMergePolicy();
}
 
源代码5 项目: lucene-solr   文件: TestFieldCache.java
@BeforeClass
public static void beforeClass() throws Exception {
  NUM_DOCS = atLeast(500);
  NUM_ORDS = atLeast(2);
  directory = newDirectory();
  IndexWriter writer= new IndexWriter(directory, new IndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(new LogDocMergePolicy()));
  long theLong = Long.MAX_VALUE;
  double theDouble = Double.MAX_VALUE;
  int theInt = Integer.MAX_VALUE;
  float theFloat = Float.MAX_VALUE;
  unicodeStrings = new String[NUM_DOCS];
  multiValued = new BytesRef[NUM_DOCS][NUM_ORDS];
  if (VERBOSE) {
    System.out.println("TEST: setUp");
  }
  for (int i = 0; i < NUM_DOCS; i++){
    Document doc = new Document();
    doc.add(new LongPoint("theLong", theLong--));
    doc.add(new DoublePoint("theDouble", theDouble--));
    doc.add(new IntPoint("theInt", theInt--));
    doc.add(new FloatPoint("theFloat", theFloat--));
    if (i%2 == 0) {
      doc.add(new IntPoint("sparse", i));
    }

    if (i%2 == 0) {
      doc.add(new IntPoint("numInt", i));
    }

    // sometimes skip the field:
    if (random().nextInt(40) != 17) {
      unicodeStrings[i] = generateString(i);
      doc.add(newStringField("theRandomUnicodeString", unicodeStrings[i], Field.Store.YES));
    }

    // sometimes skip the field:
    if (random().nextInt(10) != 8) {
      for (int j = 0; j < NUM_ORDS; j++) {
        String newValue = generateString(i);
        multiValued[i][j] = new BytesRef(newValue);
        doc.add(newStringField("theRandomUnicodeMultiValuedField", newValue, Field.Store.YES));
      }
      Arrays.sort(multiValued[i]);
    }
    writer.addDocument(doc);
  }
  writer.forceMerge(1); // this test relies on one segment and docid order
  IndexReader r = DirectoryReader.open(writer);
  assertEquals(1, r.leaves().size());
  reader = r.leaves().get(0).reader();
  TestUtil.checkReader(reader);
  writer.close();
}
 
 类所在包
 类方法
 同包方法