Search in sources :

Example 26 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class UniquenessConstraintValidationIT method createConstraint.

private ConstraintDescriptor createConstraint(String label, String propertyKey) throws KernelException {
    int labelId;
    int propertyKeyId;
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    labelId = tokenWrite.labelGetOrCreateForName(label);
    propertyKeyId = tokenWrite.propertyKeyGetOrCreateForName(propertyKey);
    commit();
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    ConstraintDescriptor constraint = schemaWrite.uniquePropertyConstraintCreate(uniqueForSchema(forLabel(labelId, propertyKeyId)));
    commit();
    return constraint;
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Example 27 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class IndexIT method createIndexForAnotherLabelWhileHoldingSharedLockOnOtherLabel.

@Test
void createIndexForAnotherLabelWhileHoldingSharedLockOnOtherLabel() throws KernelException, ExecutionException, InterruptedException {
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    int label2 = tokenWrite.labelGetOrCreateForName("Label2");
    commit();
    Write write = dataWriteInNewTransaction();
    long nodeId = write.nodeCreate();
    write.nodeAddLabel(nodeId, label2);
    try (var ignored = captureTransaction()) {
        executorService.submit(() -> {
            try {
                schemaWriteInNewTransaction().indexCreate(schema, null);
                commit();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }).get();
    }
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Write(org.neo4j.internal.kernel.api.Write) SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) SchemaKernelException(org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException) ExecutionException(java.util.concurrent.ExecutionException) KernelException(org.neo4j.exceptions.KernelException) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 28 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class SystemBuiltInProceduresIT method listPropertyKeys.

@Test
void listPropertyKeys() throws Throwable {
    // Given
    TokenWrite ops = tokenWriteInNewTransaction();
    ops.propertyKeyGetOrCreateForName("MyProp");
    commit();
    try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
        // When & Then
        assertFalse(tx.execute("CALL db.propertyKeys").hasNext());
    }
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test)

Example 29 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class SchemaCheckerTest method initialData.

@Override
void initialData(KernelTransaction tx) throws KernelException {
    TokenWrite tokenWrite = tx.tokenWrite();
    label1 = tokenWrite.labelGetOrCreateForName("A");
    label2 = tokenWrite.labelGetOrCreateForName("B");
    relationshipType1 = tokenWrite.relationshipTypeGetOrCreateForName("A");
    relationshipType2 = tokenWrite.relationshipTypeGetOrCreateForName("B");
    propertyKey1 = tokenWrite.propertyKeyGetOrCreateForName("A");
    propertyKey2 = tokenWrite.propertyKeyGetOrCreateForName("B");
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Example 30 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class SafePropertyChainReaderTest method initialData.

@Override
void initialData(KernelTransaction tx) throws KernelException {
    TokenWrite tokenWrite = tx.tokenWrite();
    propertyKey1 = tokenWrite.propertyKeyGetOrCreateForName("1");
    propertyKey2 = tokenWrite.propertyKeyGetOrCreateForName("2");
    propertyKey3 = tokenWrite.propertyKeyGetOrCreateForName("3");
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Aggregations

TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)34 Test (org.junit.jupiter.api.Test)12 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)11 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)10 Write (org.neo4j.internal.kernel.api.Write)8 BeforeEach (org.junit.jupiter.api.BeforeEach)6 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)6 KernelException (org.neo4j.exceptions.KernelException)5 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)5 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)4 Transaction (org.neo4j.graphdb.Transaction)3 RelationshipTraversalCursor (org.neo4j.internal.kernel.api.RelationshipTraversalCursor)3 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)3 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)2 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)2 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)2 ExecutionException (java.util.concurrent.ExecutionException)1 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1