Search in sources :

Example 56 with SchemaDescriptor

use of org.neo4j.internal.schema.SchemaDescriptor in project neo4j by neo4j.

the class TxStateTest method shouldAddAndGetByLabel.

@Test
void shouldAddAndGetByLabel() {
    // WHEN
    state.indexDoAdd(indexOn_1_1);
    state.indexDoAdd(indexOn_2_1);
    // THEN
    SchemaDescriptor schema = indexOn_1_1.schema();
    int[] labels = schema.getEntityTokenIds();
    assertEquals(schema.entityType(), EntityType.NODE);
    assertEquals(1, labels.length);
    assertEquals(asSet(indexOn_1_1), state.indexDiffSetsByLabel(labels[0]).getAdded());
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 57 with SchemaDescriptor

use of org.neo4j.internal.schema.SchemaDescriptor in project neo4j by neo4j.

the class BuiltInProcedures method asIndexResult.

private static IndexResult asIndexResult(TokenNameLookup tokenLookup, SchemaReadCore schemaRead, IndexDescriptor index) {
    SchemaDescriptor schema = index.schema();
    long id = index.getId();
    String name = index.getName();
    IndexStatus status = getIndexStatus(schemaRead, index);
    String uniqueness = IndexUniqueness.getUniquenessOf(index);
    String type = index.getIndexType().name();
    String entityType = index.schema().entityType().name();
    List<String> labelsOrTypes = Arrays.asList(tokenLookup.entityTokensGetNames(schema.entityType(), schema.getEntityTokenIds()));
    List<String> properties = propertyNames(tokenLookup, index);
    String provider = index.getIndexProvider().name();
    return new IndexResult(id, name, status.state, status.populationProgress, uniqueness, type, entityType, labelsOrTypes, properties, provider);
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor)

Example 58 with SchemaDescriptor

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

SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)58 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)27 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)23 Test (org.junit.jupiter.api.Test)18 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)18 RelationTypeSchemaDescriptor (org.neo4j.internal.schema.RelationTypeSchemaDescriptor)18 Value (org.neo4j.values.storable.Value)11 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)10 ArrayList (java.util.ArrayList)6 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)6 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)5 IndexConfig (org.neo4j.internal.schema.IndexConfig)5 MemoryTracker (org.neo4j.memory.MemoryTracker)5 KernelException (org.neo4j.exceptions.KernelException)4 UnspecifiedKernelException (org.neo4j.exceptions.UnspecifiedKernelException)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)4 IndexNotApplicableKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException)4 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)4 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)4