Search in sources :

Example 11 with SchemaIndexProvider

use of org.neo4j.kernel.api.index.SchemaIndexProvider in project neo4j by neo4j.

the class TestLuceneSchemaBatchInsertIT method shouldLoadAndUseLuceneProvider.

@Test
public void shouldLoadAndUseLuceneProvider() throws Exception {
    // GIVEN
    File storeDir = testDirectory.graphDbDir();
    BatchInserter inserter = BatchInserters.inserter(storeDir, fileSystemRule.get());
    inserter.createDeferredSchemaIndex(LABEL).on("name").create();
    // WHEN
    inserter.createNode(map("name", "Mattias"), LABEL);
    inserter.shutdown();
    // THEN
    GraphDatabaseFactory graphDatabaseFactory = new TestGraphDatabaseFactory();
    GraphDatabaseAPI db = (GraphDatabaseAPI) graphDatabaseFactory.newEmbeddedDatabase(storeDir);
    DependencyResolver dependencyResolver = db.getDependencyResolver();
    SchemaIndexProvider schemaIndexProvider = dependencyResolver.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
    // assert the indexProvider is a Lucene one
    try (Transaction ignore = db.beginTx()) {
        IndexDefinition indexDefinition = Iterables.single(db.schema().getIndexes(LABEL));
        assertThat(db.schema().getIndexState(indexDefinition), is(Schema.IndexState.ONLINE));
        assertThat(schemaIndexProvider, instanceOf(LuceneSchemaIndexProvider.class));
    }
    // CLEANUP
    db.shutdown();
}
Also used : LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Aggregations

SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)11 Test (org.junit.Test)5 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)5 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)4 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)4 BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)4 File (java.io.File)3 IOException (java.io.IOException)3 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)3 Dependencies (org.neo4j.kernel.impl.util.Dependencies)3 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)3 DependencyResolver (org.neo4j.graphdb.DependencyResolver)2 Transaction (org.neo4j.graphdb.Transaction)2 PageCache (org.neo4j.io.pagecache.PageCache)2 LuceneSchemaIndexProvider (org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider)2 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)2 KernelExtensions (org.neo4j.kernel.extension.KernelExtensions)2 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2