Search in sources :

Example 11 with TokenWrite

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

the class NodeGetUniqueFromIndexSeekIT method createKeys.

@BeforeEach
void createKeys() throws Exception {
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    this.labelId = tokenWrite.labelGetOrCreateForName("Person");
    this.propertyId1 = tokenWrite.propertyKeyGetOrCreateForName("foo");
    this.propertyId2 = tokenWrite.propertyKeyGetOrCreateForName("bar");
    commit();
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with TokenWrite

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

the class NodeCheckerTest method initialData.

@Override
void initialData(KernelTransaction tx) throws KernelException {
    TokenWrite tokenWrite = tx.tokenWrite();
    int[] labelIds = new int[300];
    for (int i = 0; i < labelIds.length; i++) {
        labelIds[i] = tokenWrite.labelGetOrCreateForName(String.valueOf(i));
    }
    Arrays.sort(labelIds);
    label1 = labelIds[0];
    label2 = labelIds[1];
    label3 = labelIds[2];
    otherLabels = Arrays.copyOfRange(labelIds, 3, labelIds.length);
    unusedLabel = labelIds[labelIds.length - 1] + 99;
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Example 13 with TokenWrite

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

the class IndexIT method createIndexesForDifferentLabelsConcurrently.

@Test
@Timeout(10)
void createIndexesForDifferentLabelsConcurrently() throws Throwable {
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    int label2 = tokenWrite.labelGetOrCreateForName("Label2");
    commit();
    LabelSchemaDescriptor anotherLabelDescriptor = SchemaDescriptor.forLabel(label2, propertyKeyId);
    schemaWriteInNewTransaction().indexCreate(anotherLabelDescriptor, "my index");
    Future<?> indexFuture = executorService.submit(createIndex(db, label(LABEL), PROPERTY_KEY));
    indexFuture.get();
    commit();
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest) Timeout(org.junit.jupiter.api.Timeout)

Example 14 with TokenWrite

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

the class IndexIT method createLabelAndProperty.

@BeforeEach
void createLabelAndProperty() throws Exception {
    TokenWrite tokenWrites = tokenWriteInNewTransaction();
    labelId = tokenWrites.labelGetOrCreateForName(LABEL);
    labelId2 = tokenWrites.labelGetOrCreateForName(LABEL2);
    relType = tokenWrites.relationshipTypeGetOrCreateForName(REL_TYPE);
    relType2 = tokenWrites.relationshipTypeGetOrCreateForName(REL_TYPE2);
    propertyKeyId = tokenWrites.propertyKeyGetOrCreateForName(PROPERTY_KEY);
    propertyKeyId2 = tokenWrites.propertyKeyGetOrCreateForName(PROPERTY_KEY2);
    schema = SchemaDescriptor.forLabel(labelId, propertyKeyId);
    schema2 = SchemaDescriptor.forLabel(labelId, propertyKeyId2);
    commit();
    executorService = Executors.newCachedThreadPool();
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with TokenWrite

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

the class CompositeUniquenessConstraintValidationIT method setup.

@BeforeEach
public void setup() throws Exception {
    kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
    newTransaction();
    // This transaction allocates all the tokens we'll need in this test.
    // We rely on token ids being allocated sequentially, from and including zero.
    TokenWrite tokenWrite = transaction.tokenWrite();
    tokenWrite.labelGetOrCreateForName("Label0");
    label = tokenWrite.labelGetOrCreateForName("Label1");
    propIds = new int[10];
    for (int i = 0; i < propIds.length; i++) {
        propIds[i] = tokenWrite.propertyKeyGetOrCreateForName("prop" + i);
    }
    commit();
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Kernel(org.neo4j.kernel.api.Kernel) BeforeEach(org.junit.jupiter.api.BeforeEach)

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