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));
}
}
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();
}
}
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();
}
}
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;
}
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;
}
Aggregations