Search in sources :

Example 1 with RelationshipTraversalCursor

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

the class CachingExpandIntoTest method connections.

private LongSet connections(long start, Direction direction, long end, String... types) throws TransactionFailureException {
    try (KernelTransaction tx = transaction();
        NodeCursor nodeCursor = tx.cursors().allocateNodeCursor(tx.cursorContext());
        RelationshipTraversalCursor traversalCursor = tx.cursors().allocateRelationshipTraversalCursor(tx.cursorContext())) {
        int[] typeIds = types.length == 0 ? null : stream(types).mapToInt(tx.tokenRead()::relationshipType).toArray();
        CachingExpandInto expandInto = new CachingExpandInto(tx.dataRead(), direction, MEMORY_TRACKER);
        return toSet(expandInto.connectingRelationships(nodeCursor, traversalCursor, start, typeIds, end));
    }
}
Also used : RelationshipTraversalCursor(org.neo4j.internal.kernel.api.RelationshipTraversalCursor) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor)

Example 2 with RelationshipTraversalCursor

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

the class KernelReadTracerTest method shouldTraceLazySelectionRelationshipTraversal.

@Test
void shouldTraceLazySelectionRelationshipTraversal() {
    // given
    TestKernelReadTracer tracer = new TestKernelReadTracer();
    try (NodeCursor nodeCursor = cursors.allocateNodeCursor(NULL);
        RelationshipTraversalCursor cursor = cursors.allocateRelationshipTraversalCursor(NULL)) {
        // when
        cursor.setTracer(tracer);
        read.singleNode(foo, nodeCursor);
        assertTrue(nodeCursor.next());
        int type = token.relationshipType("HAS");
        nodeCursor.relationships(cursor, selection(type, Direction.OUTGOING));
        assertTrue(cursor.next());
        tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
        cursor.removeTracer();
        assertTrue(cursor.next());
        tracer.assertEvents();
        cursor.setTracer(tracer);
        assertTrue(cursor.next());
        tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
        // skip last one
        assertTrue(cursor.next());
        tracer.clear();
        assertFalse(cursor.next());
        tracer.assertEvents();
    }
}
Also used : RelationshipTraversalCursor(org.neo4j.internal.kernel.api.RelationshipTraversalCursor) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 3 with RelationshipTraversalCursor

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

the class KernelReadTracerTest method shouldTraceRelationshipTraversal.

@Test
void shouldTraceRelationshipTraversal() {
    // given
    TestKernelReadTracer tracer = new TestKernelReadTracer();
    try (NodeCursor nodeCursor = cursors.allocateNodeCursor(NULL);
        RelationshipTraversalCursor cursor = cursors.allocateRelationshipTraversalCursor(NULL)) {
        // when
        cursor.setTracer(tracer);
        read.singleNode(foo, nodeCursor);
        assertTrue(nodeCursor.next());
        nodeCursor.relationships(cursor, ALL_RELATIONSHIPS);
        assertTrue(cursor.next());
        tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
        cursor.removeTracer();
        assertTrue(cursor.next());
        tracer.assertEvents();
        cursor.setTracer(tracer);
        assertTrue(cursor.next());
        tracer.assertEvents(OnRelationship(cursor.relationshipReference()));
        // skip last two
        assertTrue(cursor.next());
        assertTrue(cursor.next());
        tracer.clear();
        assertFalse(cursor.next());
        tracer.assertEvents();
    }
}
Also used : RelationshipTraversalCursor(org.neo4j.internal.kernel.api.RelationshipTraversalCursor) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 4 with RelationshipTraversalCursor

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

the class ManagedTestCursors method allocateFullAccessRelationshipTraversalCursor.

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

Example 5 with RelationshipTraversalCursor

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

the class ManagedTestCursors method allocateRelationshipTraversalCursor.

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

Aggregations

RelationshipTraversalCursor (org.neo4j.internal.kernel.api.RelationshipTraversalCursor)29 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)26 Test (org.junit.jupiter.api.Test)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)17 Write (org.neo4j.internal.kernel.api.Write)10 Read (org.neo4j.internal.kernel.api.Read)7 Degrees (org.neo4j.storageengine.api.Degrees)7 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)3 PropertyCursor (org.neo4j.internal.kernel.api.PropertyCursor)2 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)1 SecurityContext (org.neo4j.internal.kernel.api.security.SecurityContext)1 TestAccessMode (org.neo4j.internal.kernel.api.security.TestAccessMode)1