Search in sources :

Example 6 with RelationshipGroupDegreesStore

use of org.neo4j.internal.counts.RelationshipGroupDegreesStore 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());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) RelationshipGroupDegreesStore(org.neo4j.internal.counts.RelationshipGroupDegreesStore) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) SingleDegree(org.neo4j.storageengine.util.SingleDegree) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipGroupDegreesStore (org.neo4j.internal.counts.RelationshipGroupDegreesStore)6 Test (org.junit.jupiter.api.Test)3 DirectStoreAccess (org.neo4j.consistency.store.DirectStoreAccess)3 CountsAccessor (org.neo4j.counts.CountsAccessor)3 CountsStore (org.neo4j.counts.CountsStore)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 DependencyResolver (org.neo4j.common.DependencyResolver)2 LookupAccessorsFromRunningDb (org.neo4j.consistency.LookupAccessorsFromRunningDb)2 IndexAccessors (org.neo4j.consistency.checking.index.IndexAccessors)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)2 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)2 RecordStorageEngine (org.neo4j.internal.recordstorage.RecordStorageEngine)2 PageCache (org.neo4j.io.pagecache.PageCache)2 IndexProviderMap (org.neo4j.kernel.impl.api.index.IndexProviderMap)2 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)2 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)2 TokenHolders (org.neo4j.token.TokenHolders)2 FullCheck (org.neo4j.consistency.checking.full.FullCheck)1 InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)1 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)1