use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class ConstraintIndexCreatorTest method shouldCreateConstraintIndexForSpecifiedProvider.
@Test
void shouldCreateConstraintIndexForSpecifiedProvider() throws Exception {
// given
IndexingService indexingService = mock(IndexingService.class);
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("Groovy", "1.2");
IndexPrototype prototype = this.prototype.withIndexProvider(providerDescriptor);
IndexDescriptor index = prototype.materialise(this.index.getId());
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexingService.getIndexProxy(index)).thenReturn(indexProxy);
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, logProvider);
when(schemaRead.indexGetForName(constraint.getName())).thenReturn(IndexDescriptor.NO_INDEX);
// when
KernelTransactionImplementation transaction = createTransaction();
creator.createUniquenessConstraintIndex(transaction, constraint, prototype);
// then
assertEquals(1, kernel.transactions.size());
KernelTransactionImplementation transactionInstance = kernel.transactions.get(0);
verify(transactionInstance).indexUniqueCreate(prototype);
verify(schemaRead).indexGetForName(constraint.getName());
verifyNoMoreInteractions(schemaRead);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class SchemaRuleSerialization35 method readIndexRule.
// PRIVATE
// READ INDEX
private static IndexDescriptor readIndexRule(long id, ByteBuffer source) throws MalformedSchemaRuleException {
String providerKey = getDecodedStringFrom(source);
String providerVersion = getDecodedStringFrom(source);
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(providerKey, providerVersion);
byte indexRuleType = source.get();
Optional<String> name;
switch(indexRuleType) {
case GENERAL_INDEX:
{
SchemaDescriptor schema = readSchema(source);
name = readRuleName(source);
IndexPrototype prototype = IndexPrototype.forSchema(schema, providerDescriptor);
if (schema.isFulltextSchemaDescriptor()) {
prototype = prototype.withIndexType(IndexType.FULLTEXT);
}
if (name.isPresent()) {
prototype = prototype.withName(name.get());
} else {
prototype = prototype.withName(defaultIndexName(id));
}
return prototype.materialise(id);
}
case UNIQUE_INDEX:
{
long readOwningConstraint = source.getLong();
SchemaDescriptor schema = readSchema(source);
name = readRuleName(source);
IndexPrototype prototype = IndexPrototype.uniqueForSchema(schema, providerDescriptor);
if (name.isPresent()) {
prototype = prototype.withName(name.get());
} else {
prototype = prototype.withName(defaultIndexName(id));
}
IndexDescriptor index = prototype.materialise(id);
if (readOwningConstraint != NO_OWNING_CONSTRAINT_YET) {
index = index.withOwningConstraintId(readOwningConstraint);
}
return index;
}
default:
throw new MalformedSchemaRuleException(format("Got unknown index rule type '%d'.", indexRuleType));
}
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class SchemaStore method indexProviderToMap.
private static void indexProviderToMap(IndexDescriptor rule, Map<String, Value> map) {
IndexProviderDescriptor provider = rule.getIndexProvider();
String name = provider.getKey();
String version = provider.getVersion();
putStringProperty(map, PROP_INDEX_PROVIDER_NAME, name);
putStringProperty(map, PROP_INDEX_PROVIDER_VERSION, version);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class DefaultIndexProviderMap method completeConfiguration.
@Override
public IndexDescriptor completeConfiguration(IndexDescriptor index) {
IndexProviderDescriptor providerDescriptor = index.getIndexProvider();
IndexProvider provider = lookup(providerDescriptor);
return provider.completeConfiguration(index);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor 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;
}
Aggregations