use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class LargeNodeCursorTestBase 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 LargeNodeCursorTestBase method shouldAccessNodesByReference.
@Test
void shouldAccessNodesByReference() {
// given
try (NodeCursor nodes = cursors.allocateNodeCursor(NULL)) {
for (long id : NODE_IDS) {
// when
read.singleNode(id, nodes);
// then
assertTrue(nodes.next(), "should access defined node");
assertEquals(id, nodes.nodeReference(), "should access the correct node");
assertFalse(nodes.next(), "should only access a single node");
}
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class NodeTransactionStateTestBase method shouldSeeNewNodePropertyInTransaction.
@Test
void shouldSeeNewNodePropertyInTransaction() throws Exception {
long nodeId;
String propKey1 = "prop1";
String propKey2 = "prop2";
try (KernelTransaction tx = beginTransaction()) {
nodeId = tx.dataWrite().nodeCreate();
int prop1 = tx.token().propertyKeyGetOrCreateForName(propKey1);
int prop2 = tx.token().propertyKeyGetOrCreateForName(propKey2);
assertEquals(NO_VALUE, tx.dataWrite().nodeSetProperty(nodeId, prop1, stringValue("hello")));
assertEquals(NO_VALUE, tx.dataWrite().nodeSetProperty(nodeId, prop2, stringValue("world")));
try (NodeCursor node = tx.cursors().allocateNodeCursor(tx.cursorContext());
PropertyCursor property = tx.cursors().allocatePropertyCursor(tx.cursorContext(), tx.memoryTracker())) {
tx.dataRead().singleNode(nodeId, node);
assertTrue(node.next(), "should access node");
node.properties(property);
IntObjectHashMap<Value> foundProperties = IntObjectHashMap.newMap();
while (property.next()) {
assertNull(foundProperties.put(property.propertyKey(), property.propertyValue()), "should only find each property once");
}
assertThat(foundProperties).hasSize(2);
assertThat(foundProperties.get(prop1)).isEqualTo(stringValue("hello"));
assertThat(foundProperties.get(prop2)).isEqualTo(stringValue("world"));
assertFalse(node.next(), "should only find one node");
}
tx.commit();
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceSingleNode.
@Test
void shouldTraceSingleNode() {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
try (NodeCursor cursor = cursors.allocateNodeCursor(NULL)) {
// when
cursor.setTracer(tracer);
read.singleNode(foo, cursor);
assertTrue(cursor.next());
tracer.assertEvents(OnNode(foo));
read.singleNode(bar, cursor);
assertTrue(cursor.next());
tracer.assertEvents(OnNode(bar));
read.singleNode(bare, cursor);
assertTrue(cursor.next());
tracer.assertEvents(OnNode(bare));
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class NodeCursorTestBase method shouldNotFindDeletedNode.
@Test
void shouldNotFindDeletedNode() {
// given
try (NodeCursor nodes = cursors.allocateNodeCursor(NULL)) {
// when
read.singleNode(gone, nodes);
// then
assertFalse(nodes.next(), "should not access deleted node");
}
}
Aggregations