Search in sources :

Example 1 with NoMergePolicy

use of org.apache.lucene.index.NoMergePolicy in project lucene-solr by apache.

the class TestMergePolicyConfig method testNoMergePolicyFactoryConfig.

public void testNoMergePolicyFactoryConfig() throws Exception {
    initCore("solrconfig-nomergepolicyfactory.xml", "schema-minimal.xml");
    IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore());
    NoMergePolicy mergePolicy = assertAndCast(NoMergePolicy.class, iwc.getMergePolicy());
    assertCommitSomeNewDocs();
    assertCommitSomeNewDocs();
    assertNumSegments(h.getCore(), 2);
    assertU(optimize());
    assertNumSegments(h.getCore(), 2);
    deleteCore();
    initCore("solrconfig-nomergepolicyfactory.xml", "schema-minimal.xml");
    iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore());
    assertEquals(mergePolicy, iwc.getMergePolicy());
}
Also used : NoMergePolicy(org.apache.lucene.index.NoMergePolicy) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 2 with NoMergePolicy

use of org.apache.lucene.index.NoMergePolicy in project lucene-solr by apache.

the class TestInPlaceUpdatesStandalone method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    System.setProperty("solr.tests.intClassName", random().nextBoolean() ? "TrieIntField" : "IntPointField");
    System.setProperty("solr.tests.longClassName", random().nextBoolean() ? "TrieLongField" : "LongPointField");
    System.setProperty("solr.tests.floatClassName", random().nextBoolean() ? "TrieFloatField" : "FloatPointField");
    System.setProperty("solr.tests.doubleClassName", random().nextBoolean() ? "TrieDoubleField" : "DoublePointField");
    // we need consistent segments that aren't re-ordered on merge because we're
    // asserting inplace updates happen by checking the internal [docid]
    systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
    initCore("solrconfig-tlog.xml", "schema-inplace-updates.xml");
    // sanity check that autocommits are disabled
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoCommmitMaxTime);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoSoftCommmitMaxTime);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoCommmitMaxDocs);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoSoftCommmitMaxDocs);
    // assert that NoMergePolicy was chosen
    RefCounted<IndexWriter> iw = h.getCore().getSolrCoreState().getIndexWriter(h.getCore());
    try {
        IndexWriter writer = iw.get();
        assertTrue("Actual merge policy is: " + writer.getConfig().getMergePolicy(), writer.getConfig().getMergePolicy() instanceof NoMergePolicy);
    } finally {
        iw.decref();
    }
    // validate that the schema was not changed to an unexpected state
    IndexSchema schema = h.getCore().getLatestSchema();
    for (String fieldName : Arrays.asList("_version_", "inplace_l_dvo", "inplace_updatable_float", "inplace_updatable_int", "inplace_updatable_float_with_default", "inplace_updatable_int_with_default")) {
        // these fields must only be using docValues to support inplace updates
        SchemaField field = schema.getField(fieldName);
        assertTrue(field.toString(), field.hasDocValues() && !field.indexed() && !field.stored());
    }
    for (String fieldName : Arrays.asList("title_s", "regular_l", "stored_i")) {
        // these fields must support atomic updates, but not inplace updates (ie: stored)
        SchemaField field = schema.getField(fieldName);
        assertTrue(field.toString(), field.stored());
    }
    // Don't close this client, it would shutdown the CoreContainer
    client = new EmbeddedSolrServer(h.getCoreContainer(), h.coreName);
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) IndexWriter(org.apache.lucene.index.IndexWriter) NoMergePolicy(org.apache.lucene.index.NoMergePolicy) IndexSchema(org.apache.solr.schema.IndexSchema) StringContains.containsString(org.junit.internal.matchers.StringContains.containsString) EmbeddedSolrServer(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer) NoMergePolicyFactory(org.apache.solr.index.NoMergePolicyFactory) BeforeClass(org.junit.BeforeClass)

Example 3 with NoMergePolicy

use of org.apache.lucene.index.NoMergePolicy in project lucene-solr by apache.

the class TestInPlaceUpdatesDistrib method beforeSuperClass.

@BeforeClass
public static void beforeSuperClass() throws Exception {
    System.setProperty("solr.tests.intClassName", random().nextBoolean() ? "TrieIntField" : "IntPointField");
    System.setProperty("solr.tests.longClassName", random().nextBoolean() ? "TrieLongField" : "LongPointField");
    System.setProperty("solr.tests.floatClassName", random().nextBoolean() ? "TrieFloatField" : "FloatPointField");
    System.setProperty("solr.tests.doubleClassName", random().nextBoolean() ? "TrieDoubleField" : "DoublePointField");
    schemaString = "schema-inplace-updates.xml";
    configString = "solrconfig-tlog.xml";
    // we need consistent segments that aren't re-ordered on merge because we're
    // asserting inplace updates happen by checking the internal [docid]
    systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
    initCore(configString, schemaString);
    // sanity check that autocommits are disabled
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoCommmitMaxTime);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoSoftCommmitMaxTime);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoCommmitMaxDocs);
    assertEquals(-1, h.getCore().getSolrConfig().getUpdateHandlerInfo().autoSoftCommmitMaxDocs);
    // assert that NoMergePolicy was chosen
    RefCounted<IndexWriter> iw = h.getCore().getSolrCoreState().getIndexWriter(h.getCore());
    try {
        IndexWriter writer = iw.get();
        assertTrue("Actual merge policy is: " + writer.getConfig().getMergePolicy(), writer.getConfig().getMergePolicy() instanceof NoMergePolicy);
    } finally {
        iw.decref();
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) NoMergePolicy(org.apache.lucene.index.NoMergePolicy) NoMergePolicyFactory(org.apache.solr.index.NoMergePolicyFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

NoMergePolicy (org.apache.lucene.index.NoMergePolicy)3 IndexWriter (org.apache.lucene.index.IndexWriter)2 NoMergePolicyFactory (org.apache.solr.index.NoMergePolicyFactory)2 BeforeClass (org.junit.BeforeClass)2 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 EmbeddedSolrServer (org.apache.solr.client.solrj.embedded.EmbeddedSolrServer)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 SchemaField (org.apache.solr.schema.SchemaField)1 StringContains.containsString (org.junit.internal.matchers.StringContains.containsString)1