Search in sources :

Example 31 with LabelSchemaDescriptor

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

the class SchemaStorageIT method makeIndexRule.

private IndexDescriptor makeIndexRule(long ruleId, String label, String propertyKey) {
    LabelSchemaDescriptor schema = forLabel(labelId(label), propId(propertyKey));
    IndexPrototype prototype = forSchema(schema, GenericNativeIndexProvider.DESCRIPTOR);
    prototype = prototype.withName(SchemaRule.generateName(prototype, new String[] { label }, new String[] { propertyKey }));
    return prototype.materialise(ruleId);
}
Also used : IndexPrototype(org.neo4j.internal.schema.IndexPrototype) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor)

Example 32 with LabelSchemaDescriptor

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

the class KernelSchemaStateFlushingTest method createIndex.

private IndexDescriptor createIndex() throws KernelException {
    try (KernelTransaction transaction = beginTransaction()) {
        LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propId);
        IndexDescriptor reference = transaction.schemaWrite().indexCreate(schema, null);
        transaction.commit();
        return reference;
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 33 with LabelSchemaDescriptor

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

the class IndexPopulationFailedKernelExceptionTest method shouldHandleMultiplePropertiesInConstructor1.

@Test
void shouldHandleMultiplePropertiesInConstructor1() {
    // Given
    LabelSchemaDescriptor descriptor = SchemaDescriptor.forLabel(0, 42, 43, 44);
    // When
    IndexPopulationFailedKernelException index = new IndexPopulationFailedKernelException(descriptor.userDescription(TOKEN_NAME_LOOKUP), new RuntimeException());
    // Then
    assertThat(index.getUserMessage(TOKEN_NAME_LOOKUP)).isEqualTo("Failed to populate index (:label0 {p42, p43, p44})");
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test)

Example 34 with LabelSchemaDescriptor

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

the class IndexPopulationFailedKernelExceptionTest method shouldHandleMultiplePropertiesInConstructor2.

@Test
void shouldHandleMultiplePropertiesInConstructor2() {
    // Given
    LabelSchemaDescriptor descriptor = SchemaDescriptor.forLabel(0, 42, 43, 44);
    // When
    IndexPopulationFailedKernelException index = new IndexPopulationFailedKernelException(descriptor.userDescription(TOKEN_NAME_LOOKUP), "an act of pure evil occurred");
    // Then
    assertThat(index.getUserMessage(TOKEN_NAME_LOOKUP)).isEqualTo("Failed to populate index (:label0 {p42, p43, p44}), due to an act of pure evil occurred");
}
Also used : LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test)

Example 35 with LabelSchemaDescriptor

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

the class IndexEntryConflictExceptionTest method shouldMakeCompositeEntryConflicts.

@Test
void shouldMakeCompositeEntryConflicts() {
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, 2, 3, 4);
    ValueTuple values = ValueTuple.of(true, "hi", new long[] { 6L, 4L });
    IndexEntryConflictException e = new IndexEntryConflictException(0L, 1L, values);
    assertThat(e.evidenceMessage(tokens, schema)).isEqualTo("Both Node(0) and Node(1) have the label `label1` and properties `p2` = true, `p3` = 'hi', `p4` = [6, 4]");
}
Also used : ValueTuple(org.neo4j.values.storable.ValueTuple) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)63 Test (org.junit.jupiter.api.Test)41 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)24 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)16 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)5 UniquenessConstraintDescriptor (org.neo4j.internal.schema.constraints.UniquenessConstraintDescriptor)5 Value (org.neo4j.values.storable.Value)5 Transaction (org.neo4j.graphdb.Transaction)4 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)4 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)4 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)4 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 RepeatedTest (org.junit.jupiter.api.RepeatedTest)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)3 Node (org.neo4j.graphdb.Node)3 TokenRead (org.neo4j.internal.kernel.api.TokenRead)3 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)3 IndexConfig (org.neo4j.internal.schema.IndexConfig)3