Search in sources :

Example 1 with RelationshipTypeIndexCursor

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

the class ManagedTestCursors method allocateRelationshipTypeIndexCursor.

@Override
public RelationshipTypeIndexCursor allocateRelationshipTypeIndexCursor(CursorContext cursorContext) {
    RelationshipTypeIndexCursor n = cursors.allocateRelationshipTypeIndexCursor(cursorContext);
    allCursors.add(n);
    return n;
}
Also used : RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor)

Example 2 with RelationshipTypeIndexCursor

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

the class ManagedTestCursors method allocateFullAccessRelationshipTypeIndexCursor.

@Override
public RelationshipTypeIndexCursor allocateFullAccessRelationshipTypeIndexCursor() {
    RelationshipTypeIndexCursor n = cursors.allocateFullAccessRelationshipTypeIndexCursor();
    allCursors.add(n);
    return n;
}
Also used : RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor)

Example 3 with RelationshipTypeIndexCursor

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

the class KernelReadTracerTxStateTest method shouldTraceRelationshipTypeScan.

@Test
void shouldTraceRelationshipTypeScan() throws KernelException {
    // given
    TestKernelReadTracer tracer = new TestKernelReadTracer();
    try (KernelTransaction tx = beginTransaction();
        RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
        int rType = tx.token().relationshipTypeGetOrCreateForName("R");
        long n1 = tx.dataWrite().nodeCreate();
        long n2 = tx.dataWrite().nodeCreate();
        tx.dataWrite().relationshipCreate(n1, rType, n2);
        // when
        cursor.setTracer(tracer);
        tx.dataRead().relationshipTypeScan(getTokenReadSession(tx, EntityType.RELATIONSHIP), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(rType));
        tracer.assertEvents(OnRelationshipTypeScan(rType));
        assertTrue(cursor.next());
        tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
        assertFalse(cursor.next());
        tracer.assertEvents();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor) Test(org.junit.jupiter.api.Test)

Example 4 with RelationshipTypeIndexCursor

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

the class RelationshipTypeIndexCursorTestBase method shouldTraceRelationshipTypeScanEvents.

@Test
void shouldTraceRelationshipTypeScanEvents() throws KernelException {
    long first;
    long second;
    long third;
    try (KernelTransaction tx = beginTransaction()) {
        first = createRelationship(tx.dataWrite(), typeOne);
        second = createRelationship(tx.dataWrite(), typeTwo);
        third = createRelationship(tx.dataWrite(), typeTwo);
        tx.commit();
    }
    try (KernelTransaction tx = beginTransaction()) {
        org.neo4j.internal.kernel.api.Read read = tx.dataRead();
        try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
            TestKernelReadTracer tracer = new TestKernelReadTracer();
            cursor.setTracer(tracer);
            // when
            relationshipTypeScan(tx, typeOne, cursor, IndexOrder.NONE);
            exhaustCursor(cursor);
            // then
            tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeOne), new TraceEvent(Relationship, first));
            // when
            relationshipTypeScan(tx, typeTwo, cursor, IndexOrder.NONE);
            exhaustCursor(cursor);
            // then
            tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeTwo), new TraceEvent(Relationship, second), new TraceEvent(Relationship, third));
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor) TraceEvent(org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with RelationshipTypeIndexCursor

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

the class RelationshipTypeIndexCursorTestBase method shouldFindRelationshipsByTypeInTx.

@ParameterizedTest
@EnumSource(value = IndexOrder.class)
void shouldFindRelationshipsByTypeInTx(IndexOrder order) throws KernelException {
    long inStore;
    long inStore2;
    long deletedInTx;
    long createdInTx;
    long createdInTx2;
    try (KernelTransaction tx = beginTransaction()) {
        inStore = createRelationship(tx.dataWrite(), typeOne);
        createRelationship(tx.dataWrite(), typeTwo);
        deletedInTx = createRelationship(tx.dataWrite(), typeOne);
        inStore2 = createRelationship(tx.dataWrite(), typeOne);
        tx.commit();
    }
    try (KernelTransaction tx = beginTransaction()) {
        tx.dataWrite().relationshipDelete(deletedInTx);
        createdInTx = createRelationship(tx.dataWrite(), typeOne);
        createRelationship(tx.dataWrite(), typeTwo);
        createdInTx2 = createRelationship(tx.dataWrite(), typeOne);
        try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
            MutableLongSet uniqueIds = new LongHashSet();
            // when
            relationshipTypeScan(tx, typeOne, cursor, order);
            // then
            assertRelationships(cursor, uniqueIds, order, inStore, inStore2, createdInTx, createdInTx2);
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RelationshipTypeIndexCursor (org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor)7 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)2 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)2 TraceEvent (org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent)2 ArrayList (java.util.ArrayList)1