Search in sources :

Example 31 with IndexProvider

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

the class DefaultIndexProviderMapTest method shouldNotSupportMultipleProvidersWithSameDescriptor.

@Test
void shouldNotSupportMultipleProvidersWithSameDescriptor() {
    // given
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(provider("provider", "1.2"));
    dependencies.satisfyDependency(fulltext());
    dependencies.satisfyDependency(tokenProvider());
    // when
    assertThrows(IllegalArgumentException.class, () -> createDefaultProviderMap(dependencies, provider.getProviderDescriptor()).init());
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 32 with IndexProvider

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

the class DefaultIndexProviderMapTest method provider.

private static IndexProvider provider(String name, String version) {
    IndexProviderDescriptor descriptor = new IndexProviderDescriptor(name, version);
    IndexProvider provider = mock(IndexProvider.class);
    when(provider.getProviderDescriptor()).thenReturn(descriptor);
    return provider;
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor)

Example 33 with IndexProvider

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

the class DefaultIndexProviderMapTest method shouldInitializeTokenIndexProvider.

@Test
void shouldInitializeTokenIndexProvider() {
    // given
    IndexProvider tokenIndexProvider = tokenProvider();
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(tokenIndexProvider);
    // when
    DefaultIndexProviderMap defaultIndexProviderMap = new DefaultIndexProviderMap(dependencies, Config.newBuilder().set(GraphDatabaseSettings.default_schema_provider, provider.getProviderDescriptor().name()).build());
    defaultIndexProviderMap.init();
    Assertions.assertThat(defaultIndexProviderMap.getTokenIndexProvider()).isEqualTo(tokenIndexProvider);
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 34 with IndexProvider

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

the class IndexConfigMigrator method migrateIndexConfig.

public static SchemaRule migrateIndexConfig(SchemaRule rule, DatabaseLayout directoryLayout, FileSystemAbstraction fs, PageCache pageCache, IndexProviderMap indexProviderMap, Log log, CursorContext cursorContext) throws IOException {
    if (rule instanceof IndexDescriptor) {
        IndexDescriptor old = (IndexDescriptor) rule;
        long indexId = old.getId();
        IndexProviderDescriptor provider = old.getIndexProvider();
        IndexMigration indexMigration = IndexMigration.migrationFromOldProvider(provider.getKey(), provider.getVersion());
        IndexConfig indexConfig = indexMigration.extractIndexConfig(fs, pageCache, directoryLayout, indexId, cursorContext, log);
        IndexDescriptor newIndexReference = old.withIndexConfig(indexConfig);
        IndexProvider indexProvider = indexProviderMap.lookup(indexMigration.desiredAlternativeProvider);
        return indexProvider.completeConfiguration(newIndexReference);
    }
    return rule;
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 35 with IndexProvider

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

the class IndexingService method validateIndexPrototype.

@Override
public void validateIndexPrototype(IndexPrototype prototype) {
    IndexProvider provider = providerMap.lookup(prototype.getIndexProvider());
    provider.validatePrototype(prototype);
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider)

Aggregations

IndexProvider (org.neo4j.kernel.api.index.IndexProvider)40 Test (org.junit.jupiter.api.Test)23 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)17 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)14 ArrayList (java.util.ArrayList)9 Config (org.neo4j.configuration.Config)9 GenericNativeIndexProvider (org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider)7 DefaultIndexProviderMap (org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap)7 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 IndexSample (org.neo4j.kernel.api.index.IndexSample)6 TokenNameLookup (org.neo4j.common.TokenNameLookup)5 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)5 TokenIndexProvider (org.neo4j.kernel.impl.index.schema.TokenIndexProvider)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 IOException (java.io.IOException)4 String.format (java.lang.String.format)4 Arrays (java.util.Arrays)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4