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