use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class NodeCursorTestBase method shouldNotAccessNegativeReferences.
// This is functionality which is only required for the hacky db.schema not to leak real data
@Test
void shouldNotAccessNegativeReferences() {
// given
try (NodeCursor node = cursors.allocateNodeCursor(NULL)) {
// when
read.singleNode(-2L, node);
// then
assertFalse(node.next(), "should not access negative reference node");
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class NodeCursorTestBase method shouldScanNodes.
@Test
void shouldScanNodes() {
// given
List<Long> ids = new ArrayList<>();
try (NodeCursor nodes = cursors.allocateNodeCursor(NULL)) {
// when
read.allNodesScan(nodes);
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
}
// then
assertEquals(NODE_IDS, ids);
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTraceAllNodesScan.
@Test
void shouldTraceAllNodesScan() throws Exception {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (KernelTransaction tx = beginTransaction();
NodeCursor cursor = tx.cursors().allocateNodeCursor(tx.cursorContext())) {
tx.dataWrite().nodeCreate();
tx.dataWrite().nodeCreate();
// when
cursor.setTracer(tracer);
tx.dataRead().allNodesScan(cursor);
tracer.assertEvents(ON_ALL_NODES_SCAN);
assertTrue(cursor.next());
tracer.assertEvents(OnNode(cursor.nodeReference()));
assertTrue(cursor.next());
tracer.assertEvents(OnNode(cursor.nodeReference()));
assertFalse(cursor.next());
tracer.assertEvents();
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTraceRelationshipTraversal.
@Test
void shouldTraceRelationshipTraversal() throws Exception {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (KernelTransaction tx = beginTransaction();
NodeCursor nodeCursor = tx.cursors().allocateNodeCursor(tx.cursorContext());
RelationshipTraversalCursor cursor = tx.cursors().allocateRelationshipTraversalCursor(tx.cursorContext())) {
long n1 = tx.dataWrite().nodeCreate();
long n2 = tx.dataWrite().nodeCreate();
long r = tx.dataWrite().relationshipCreate(n1, tx.token().relationshipTypeGetOrCreateForName("R"), n2);
// when
cursor.setTracer(tracer);
tx.dataRead().singleNode(n1, nodeCursor);
assertTrue(nodeCursor.next());
nodeCursor.relationships(cursor, ALL_RELATIONSHIPS);
assertTrue(cursor.next());
tracer.assertEvents(OnRelationship(r));
assertFalse(cursor.next());
tracer.assertEvents();
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class KernelReadTracerTxStateTest method shouldTracePropertyAccess.
@Test
void shouldTracePropertyAccess() throws Exception {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (KernelTransaction tx = beginTransaction();
NodeCursor nodeCursor = tx.cursors().allocateNodeCursor(tx.cursorContext());
PropertyCursor propertyCursor = tx.cursors().allocatePropertyCursor(tx.cursorContext(), tx.memoryTracker())) {
long n = tx.dataWrite().nodeCreate();
int name = tx.token().propertyKey("name");
tx.dataWrite().nodeSetProperty(n, name, Values.stringValue("Bosse"));
// when
propertyCursor.setTracer(tracer);
tx.dataRead().singleNode(n, nodeCursor);
assertTrue(nodeCursor.next());
nodeCursor.properties(propertyCursor);
assertTrue(propertyCursor.next());
tracer.assertEvents(OnProperty(name));
assertFalse(propertyCursor.next());
tracer.assertEvents();
}
}
Aggregations