Search in sources :

Example 11 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class SchemaRuleDeserializer2_0to3_1 method readIndexRule.

// === INDEX RULES ===
private static IndexDescriptor readIndexRule(long id, boolean constraintIndex, int label, ByteBuffer serialized) {
    String providerKey = getDecodedStringFrom(serialized);
    String providerVersion = getDecodedStringFrom(serialized);
    IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(providerKey, providerVersion);
    int[] propertyKeyIds = readIndexPropertyKeys(serialized);
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(label, propertyKeyIds);
    String name = defaultIndexName(id);
    if (constraintIndex) {
        return IndexPrototype.uniqueForSchema(schema, providerDescriptor).withName(name).materialise(id).withOwningConstraintId(readOwningConstraint(serialized));
    } else {
        return IndexPrototype.forSchema(schema, providerDescriptor).withName(name).materialise(id);
    }
}
Also used : IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor)

Example 12 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class SchemaStore method buildIndexRule.

private static SchemaRule buildIndexRule(long schemaRuleId, Map<String, Value> props) throws MalformedSchemaRuleException {
    SchemaDescriptor schema = buildSchemaDescriptor(props);
    String indexRuleType = getString(PROP_INDEX_RULE_TYPE, props);
    boolean unique = parseIndexType(indexRuleType);
    IndexPrototype prototype = unique ? IndexPrototype.uniqueForSchema(schema) : IndexPrototype.forSchema(schema);
    prototype = prototype.withName(getString(PROP_SCHEMA_RULE_NAME, props));
    prototype = prototype.withIndexType(getIndexType(getString(PROP_INDEX_TYPE, props)));
    String providerKey = getString(PROP_INDEX_PROVIDER_NAME, props);
    String providerVersion = getString(PROP_INDEX_PROVIDER_VERSION, props);
    IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(providerKey, providerVersion);
    prototype = prototype.withIndexProvider(providerDescriptor);
    IndexDescriptor index = prototype.materialise(schemaRuleId);
    IndexConfig indexConfig = extractIndexConfig(props);
    index = index.withIndexConfig(indexConfig);
    if (props.containsKey(PROP_OWNING_CONSTRAINT)) {
        index = index.withOwningConstraintId(getLong(PROP_OWNING_CONSTRAINT, props));
    }
    return index;
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 13 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class SchemaAcceptanceTest method mustCreateFullTextIndexBySettingIndexType.

@Test
void mustCreateFullTextIndexBySettingIndexType() {
    try (Transaction tx = db.beginTx()) {
        IndexCreator creator = tx.schema().indexFor(label).on(propertyKey).withIndexType(IndexType.FULLTEXT);
        IndexDefinition definition = creator.create();
        assertEquals(IndexType.FULLTEXT, definition.getIndexType());
        IndexProviderDescriptor provider = ((IndexDefinitionImpl) definition).getIndexReference().getIndexProvider();
        assertEquals(provider, FulltextIndexProviderFactory.DESCRIPTOR);
        tx.commit();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexCreator(org.neo4j.graphdb.schema.IndexCreator) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class DefaultIndexProviderMap method init.

@Override
public void init() {
    Iterable<IndexProvider> indexProviders = dependencies.resolveTypeDependencies(IndexProvider.class);
    for (IndexProvider provider : indexProviders) {
        IndexProviderDescriptor providerDescriptor = provider.getProviderDescriptor();
        requireNonNull(providerDescriptor);
        IndexProvider existing = put(providerDescriptor, provider);
        if (existing != null) {
            throw new IllegalArgumentException("Tried to load multiple schema index providers with the same provider descriptor " + providerDescriptor + ". First loaded " + existing + " then " + provider);
        }
    }
    initDefaultProviders();
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) TokenIndexProvider(org.neo4j.kernel.impl.index.schema.TokenIndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor)

Example 15 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class DefaultIndexProviderMapTest method shouldThrowOnLookupOnUnknownProvider.

@Test
void shouldThrowOnLookupOnUnknownProvider() {
    // given
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(fulltext());
    dependencies.satisfyDependency(tokenProvider());
    // when
    DefaultIndexProviderMap defaultIndexProviderMap = createDefaultProviderMap(dependencies, provider.getProviderDescriptor());
    defaultIndexProviderMap.init();
    assertThrows(IndexProviderNotFoundException.class, () -> defaultIndexProviderMap.lookup(new IndexProviderDescriptor("provider2", "1.2")));
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Aggregations

IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)41 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)18 Test (org.junit.jupiter.api.Test)16 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)11 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)10 ArrayList (java.util.ArrayList)5 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)5 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)5 IndexConfig (org.neo4j.internal.schema.IndexConfig)4 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)4 Path (java.nio.file.Path)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 String.format (java.lang.String.format)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 EnumMap (java.util.EnumMap)2 HashMap (java.util.HashMap)2