use of org.neo4j.internal.schema.IndexProviderDescriptor 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