use of org.neo4j.storageengine.util.SingleDegree in project neo4j by neo4j.
the class RecordStorageReaderRelTypesAndDegreeTest method degree.
private static int degree(StorageNodeCursor cursor, RelationshipSelection selection) {
SingleDegree degree = new SingleDegree();
cursor.degrees(selection, degree, true);
return degree.getTotal();
}
use of org.neo4j.storageengine.util.SingleDegree in project neo4j by neo4j.
the class DefaultNodeCursor method degree.
@Override
public int degree(RelationshipSelection selection) {
SingleDegree degrees = new SingleDegree();
fillDegrees(selection, degrees);
return degrees.getTotal();
}
use of org.neo4j.storageengine.util.SingleDegree in project neo4j by neo4j.
the class DefaultNodeCursor method degreeWithMax.
@Override
public int degreeWithMax(int maxDegree, RelationshipSelection selection) {
SingleDegree degrees = new SingleDegree(maxDegree);
fillDegrees(selection, degrees);
return Math.min(degrees.getTotal(), maxDegree);
}
use of org.neo4j.storageengine.util.SingleDegree in project neo4j by neo4j.
the class RecordNodeCursorTest method shouldChooseFastTotalDegreeLookupWhenPossible.
@Test
void shouldChooseFastTotalDegreeLookupWhenPossible() {
// given
NodeStore nodeStore = mock(NodeStore.class);
long relationshipId = 99;
long nextRelationshipId = relationshipId + 1;
long nodeId = 5;
int degree = 123;
when(nodeStore.getHighestPossibleIdInUse(NULL)).thenReturn(nodeId + 1);
doAnswer(invocationOnMock -> {
long id = invocationOnMock.getArgument(0);
NodeRecord record = invocationOnMock.getArgument(1);
record.setId(id);
record.initialize(true, NULL_REFERENCE.longValue(), false, relationshipId, NO_LABELS_FIELD.longValue());
return null;
}).when(nodeStore).getRecordByCursor(eq(nodeId), any(), any(), any());
RelationshipStore relationshipStore = mock(RelationshipStore.class);
doAnswer(invocationOnMock -> {
long id = invocationOnMock.getArgument(0);
RelationshipRecord record = invocationOnMock.getArgument(1);
record.setId(id);
record.initialize(true, NULL_REFERENCE.longValue(), nodeId, nodeId + 10, 1, degree, nextRelationshipId, 33, 44, true, false);
return null;
}).when(relationshipStore).getRecordByCursor(eq(relationshipId), any(), any(), any());
RelationshipGroupStore groupStore = mock(RelationshipGroupStore.class);
RelationshipGroupDegreesStore groupDegreesStore = mock(RelationshipGroupDegreesStore.class);
RecordNodeCursor nodeCursor = new RecordNodeCursor(nodeStore, relationshipStore, groupStore, groupDegreesStore, NULL);
// when
nodeCursor.single(nodeId);
assertThat(nodeCursor.next()).isTrue();
SingleDegree mutator = new SingleDegree();
nodeCursor.degrees(RelationshipSelection.ALL_RELATIONSHIPS, mutator, true);
// then
assertThat(mutator.getTotal()).isEqualTo(degree);
verifyNoInteractions(groupStore);
verify(relationshipStore).getRecordByCursor(eq(relationshipId), any(), any(), any());
verify(relationshipStore, never()).getRecordByCursor(eq(nextRelationshipId), any(), any(), any());
}
Aggregations