use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class DefaultPooledCursorsTestBase method shouldReuseRelationshipTraversalCursor.
@Test
void shouldReuseRelationshipTraversalCursor() {
NodeCursor node = cursors.allocateNodeCursor(NULL);
RelationshipTraversalCursor c1 = cursors.allocateRelationshipTraversalCursor(NULL);
read.singleNode(startNode, node);
node.next();
node.relationships(c1, ALL_RELATIONSHIPS);
node.close();
c1.close();
RelationshipTraversalCursor c2 = cursors.allocateRelationshipTraversalCursor(NULL);
assertThat(c1).isSameAs(c2);
c2.close();
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class CompositeUniquenessConstraintValidationIT method clean.
@AfterEach
public void clean() throws Exception {
if (transaction != null) {
transaction.close();
transaction = null;
}
newTransaction();
transaction.schemaWrite().constraintDrop(constraintDescriptor);
commit();
try (KernelTransaction tx = kernel.beginTransaction(KernelTransaction.Type.IMPLICIT, LoginContext.AUTH_DISABLED)) {
try (NodeCursor node = tx.cursors().allocateNodeCursor(tx.cursorContext())) {
tx.dataRead().allNodesScan(node);
while (node.next()) {
tx.dataWrite().nodeDelete(node.nodeReference());
}
}
tx.commit();
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class KernelIT method txReturnsCorrectIdWhenReadOnly.
@Test
void txReturnsCorrectIdWhenReadOnly() throws Exception {
executeDummyTxs(db, 42);
KernelTransaction tx = newTransaction();
try (NodeCursor node = tx.cursors().allocateNodeCursor(tx.cursorContext())) {
tx.dataRead().singleNode(1, node);
node.next();
}
assertEquals(KernelTransaction.READ_ONLY_ID, tx.commit());
assertFalse(tx.isOpen());
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class RelationshipTransactionStateTestBase method shouldSeeRelationshipInTransaction.
@Test
void shouldSeeRelationshipInTransaction() throws Exception {
long n1, n2;
try (KernelTransaction tx = beginTransaction()) {
n1 = tx.dataWrite().nodeCreate();
n2 = tx.dataWrite().nodeCreate();
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
int label = tx.tokenWrite().relationshipTypeGetOrCreateForName("R");
long r = tx.dataWrite().relationshipCreate(n1, label, n2);
try (NodeCursor node = tx.cursors().allocateNodeCursor(NULL);
RelationshipTraversalCursor relationship = tx.cursors().allocateRelationshipTraversalCursor(NULL)) {
tx.dataRead().singleNode(n1, node);
assertTrue(node.next(), "should access node");
node.relationships(relationship, ALL_RELATIONSHIPS);
assertTrue(relationship.next(), "should find relationship");
assertEquals(r, relationship.relationshipReference());
assertFalse(relationship.next(), "should only find one relationship");
}
tx.commit();
}
}
use of org.neo4j.internal.kernel.api.NodeCursor in project neo4j by neo4j.
the class RelationshipTransactionStateTestBase method shouldNewRelationshipBetweenAlreadyConnectedSparseNodes.
@Test
void shouldNewRelationshipBetweenAlreadyConnectedSparseNodes() throws Exception {
long start;
long end;
long existingRelationship;
int type;
try (KernelTransaction tx = beginTransaction()) {
Write write = tx.dataWrite();
start = write.nodeCreate();
end = write.nodeCreate();
type = tx.tokenWrite().relationshipTypeGetOrCreateForName("R");
existingRelationship = write.relationshipCreate(start, type, end);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
Write write = tx.dataWrite();
long newRelationship = write.relationshipCreate(start, type, write.nodeCreate());
try (NodeCursor node = tx.cursors().allocateNodeCursor(NULL);
RelationshipTraversalCursor traversal = tx.cursors().allocateRelationshipTraversalCursor(NULL)) {
org.neo4j.internal.kernel.api.Read read = tx.dataRead();
read.singleNode(start, node);
assertTrue(node.next());
assertFalse(node.supportsFastDegreeLookup());
Degrees degrees = node.degrees(selection(type, BOTH));
assertEquals(2, degrees.outgoingDegree());
assertEquals(0, degrees.incomingDegree());
assertRelationships(OUTGOING, node, type, traversal, newRelationship, existingRelationship);
}
}
}
Aggregations