use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class IndexProviderTests method validatePrototypeMustThrowOnInvalidPrototype.
@Test
void validatePrototypeMustThrowOnInvalidPrototype() {
// given
provider = newProvider();
// when
List<IndexPrototype> invalidPrototypes = invalidPrototypes();
// then
for (IndexPrototype invalidPrototype : invalidPrototypes) {
assertThrows(IllegalArgumentException.class, () -> provider.validatePrototype(invalidPrototype));
}
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class IndexProcedures method createUniquePropertyConstraint.
public Stream<BuiltInProcedures.SchemaIndexInfo> createUniquePropertyConstraint(String constraintName, List<String> labels, List<String> properties, IndexProviderDescriptor indexProviderDescriptor, Map<String, Object> configMap) throws ProcedureException {
return createIndex(constraintName, labels, properties, indexProviderDescriptor, configMap, "uniqueness constraint online", (schemaWrite, name, schema, provider, indexConfig) -> {
final IndexPrototype prototype = IndexPrototype.uniqueForSchema(schema, provider).withName(name).withIndexConfig(indexConfig);
schemaWrite.uniquePropertyConstraintCreate(prototype);
});
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class IndexProcedures method createIndex.
public Stream<BuiltInProcedures.SchemaIndexInfo> createIndex(String indexName, List<String> labels, List<String> properties, IndexProviderDescriptor indexProviderDescriptor, Map<String, Object> configMap) throws ProcedureException {
return createIndex(indexName, labels, properties, indexProviderDescriptor, configMap, "index created", (schemaWrite, name, descriptor, provider, indexConfig) -> {
IndexPrototype prototype = IndexPrototype.forSchema(descriptor, provider).withName(name).withIndexConfig(indexConfig);
schemaWrite.indexCreate(prototype);
});
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class IndexWriterStep method createIndex.
private IndexDescriptor createIndex(EntityType entityType, IndexConfig config, SchemaRuleAccess schemaRule, SchemaStore schemaStore, MemoryTracker memoryTracker, CursorContext cursorContext) {
try {
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("token-lookup", "1.0");
IndexPrototype prototype = forSchema(forAnyEntityTokens(entityType)).withIndexType(LOOKUP).withIndexProvider(providerDescriptor);
String name = defaultIfEmpty(config.indexName(entityType), generateName(prototype, new String[] {}, new String[] {}));
IndexDescriptor descriptor = prototype.withName(name).materialise(schemaStore.nextId(cursorContext));
schemaRule.writeSchemaRule(descriptor, cursorContext, memoryTracker);
return descriptor;
} catch (KernelException e) {
throw new RuntimeException("Error preparing indexes", e);
}
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class RandomSchema method nextIndex.
public IndexDescriptor nextIndex() {
int choice = rng.nextInt(4);
SchemaDescriptor schema;
switch(choice) {
case 0:
schema = nextNodeSchema();
break;
case 1:
schema = nextNodeFulltextSchema();
break;
case 2:
schema = nextRelationshipSchema();
break;
case 3:
schema = nextRelationshipFulltextSchema();
break;
default:
throw new RuntimeException("Bad index choice: " + choice);
}
boolean isUnique = rng.nextBoolean() && !schema.isFulltextSchemaDescriptor();
IndexPrototype prototype = isUnique ? IndexPrototype.uniqueForSchema(schema) : IndexPrototype.forSchema(schema);
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(nextName(), nextName());
prototype = prototype.withIndexProvider(providerDescriptor);
prototype = prototype.withName(nextName());
if (schema.isFulltextSchemaDescriptor()) {
prototype = prototype.withIndexType(IndexType.FULLTEXT);
}
long ruleId = nextRuleIdForIndex();
IndexDescriptor index = prototype.materialise(ruleId);
if (isUnique && rng.nextBoolean()) {
index = index.withOwningConstraintId(existingConstraintId());
}
return index;
}
Aggregations