Search in sources :

Example 11 with IndexConfig

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

the class GenericNativeIndexProvider method validatePrototype.

@Override
public void validatePrototype(IndexPrototype prototype) {
    super.validatePrototype(prototype);
    if (!(prototype.schema().isLabelSchemaDescriptor() || prototype.schema().isRelationshipTypeSchemaDescriptor())) {
        throw new IllegalArgumentException("The " + prototype.schema() + " index schema is not a btree index schema, which it is required to be for the '" + getProviderDescriptor().name() + "' index provider to be able to create an index.");
    }
    IndexConfig indexConfig = prototype.getIndexConfig();
    indexConfig = completeSpatialConfiguration(indexConfig);
    try {
        SpatialIndexConfig.validateSpatialConfig(indexConfig);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Invalid spatial index settings.", e);
    }
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig)

Example 12 with IndexConfig

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

the class GenericNativeIndexProvider method completeConfiguration.

@Override
public IndexDescriptor completeConfiguration(IndexDescriptor index) {
    IndexConfig indexConfig = index.getIndexConfig();
    indexConfig = completeSpatialConfiguration(indexConfig);
    index = index.withIndexConfig(indexConfig);
    if (index.getCapability().equals(IndexCapability.NO_CAPABILITY)) {
        index = index.withIndexCapability(CAPABILITY);
    }
    return index;
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig)

Example 13 with IndexConfig

use of org.neo4j.internal.schema.IndexConfig 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 14 with IndexConfig

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

the class FusionIndexProvider method completeConfiguration.

@Override
public IndexDescriptor completeConfiguration(IndexDescriptor index) {
    EnumMap<IndexSlot, IndexDescriptor> descriptors = new EnumMap<>(IndexSlot.class);
    EnumMap<IndexSlot, IndexCapability> capabilities = new EnumMap<>(IndexSlot.class);
    for (IndexSlot slot : IndexSlot.values()) {
        IndexDescriptor result = providers.select(slot).completeConfiguration(index);
        descriptors.put(slot, result);
        capabilities.put(slot, result.getCapability());
    }
    IndexConfig config = index.getIndexConfig();
    for (IndexDescriptor result : descriptors.values()) {
        IndexConfig resultConfig = result.getIndexConfig();
        for (Pair<String, Value> entry : resultConfig.entries()) {
            config = config.withIfAbsent(entry.getOne(), entry.getTwo());
        }
    }
    index = index.withIndexConfig(config);
    if (index.getCapability().equals(IndexCapability.NO_CAPABILITY)) {
        index = index.withIndexCapability(new FusionIndexCapability(slotSelector, new InstanceSelector<>(capabilities)));
    }
    return index;
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexCapability(org.neo4j.internal.schema.IndexCapability) Value(org.neo4j.values.storable.Value) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) EnumMap(java.util.EnumMap)

Example 15 with IndexConfig

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

the class GenericConfigExtractorTest method shouldBeAbleToExtractConfigFromHealthy35File.

@Test
void shouldBeAbleToExtractConfigFromHealthy35File() throws IOException {
    // given
    unzip(getClass(), ZIP_HEALTHY_GENERIC_35_FILE, directory.homePath());
    Path genericFile = directory.file(HEALTHY_GENERIC_35_FILE);
    // and
    assertTrue(fs.fileExists(genericFile));
    // when
    IndexConfig indexConfig = GenericConfigExtractor.indexConfigFromGenericFile(fs, pageCache, genericFile, NULL, NullLog.getInstance(), DEFAULT_DATABASE_NAME);
    // then
    assertExpectedIndexConfig(indexConfig);
}
Also used : Path(java.nio.file.Path) IndexConfig(org.neo4j.internal.schema.IndexConfig) Test(org.junit.jupiter.api.Test)

Aggregations

IndexConfig (org.neo4j.internal.schema.IndexConfig)21 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)10 Test (org.junit.jupiter.api.Test)9 Value (org.neo4j.values.storable.Value)6 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)5 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)4 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)4 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)4 HashMap (java.util.HashMap)3 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)3 Path (java.nio.file.Path)2 StringJoiner (java.util.StringJoiner)2 Config (org.neo4j.configuration.Config)2 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)2 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)2 SpaceFillingCurveSettings (org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings)2 BooleanValue (org.neo4j.values.storable.BooleanValue)2 DoubleArray (org.neo4j.values.storable.DoubleArray)2 IntValue (org.neo4j.values.storable.IntValue)2 StringValue (org.neo4j.values.storable.StringValue)2