use of org.neo4j.storageengine.api.Degrees in project neo4j by neo4j.
the class CachingExpandIntoTest method shouldComputeDegreeWithoutType.
@Test
void shouldComputeDegreeWithoutType() throws Exception {
// GIVEN
long node;
try (KernelTransaction tx = transaction()) {
Write write = tx.dataWrite();
node = nodeWithDegree(tx, 42);
relate(tx, node, "R1", write.nodeCreate());
relate(tx, node, "R2", write.nodeCreate());
relate(tx, write.nodeCreate(), "R3", node);
relate(tx, node, "R4", node);
tx.commit();
}
try (KernelTransaction tx = transaction()) {
Read read = tx.dataRead();
CursorFactory cursors = tx.cursors();
try (NodeCursor nodes = cursors.allocateNodeCursor(tx.cursorContext())) {
CachingExpandInto expand = new CachingExpandInto(tx.dataRead(), OUTGOING, MEMORY_TRACKER);
read.singleNode(node, nodes);
assertThat(nodes.next()).isEqualTo(true);
assertThat(nodes.supportsFastDegreeLookup()).isEqualTo(true);
Degrees degrees = nodes.degrees(ALL_RELATIONSHIPS);
assertThat(degrees.outgoingDegree()).isEqualTo(45);
assertThat(degrees.incomingDegree()).isEqualTo(2);
assertThat(degrees.totalDegree()).isEqualTo(46);
}
}
}
Aggregations