Search in sources :

Example 41 with IndexProviderDescriptor

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;
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) RelationTypeSchemaDescriptor(org.neo4j.internal.schema.RelationTypeSchemaDescriptor) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Aggregations

IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)41 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)18 Test (org.junit.jupiter.api.Test)16 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)11 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)10 ArrayList (java.util.ArrayList)5 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)5 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)5 IndexConfig (org.neo4j.internal.schema.IndexConfig)4 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)4 Path (java.nio.file.Path)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 String.format (java.lang.String.format)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 EnumMap (java.util.EnumMap)2 HashMap (java.util.HashMap)2