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);
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations