Search in sources :

Example 1 with FlatRelationshipModifications

use of org.neo4j.internal.recordstorage.FlatRelationshipModifications in project neo4j by neo4j.

the class DegreesRebuildFromStoreTest method generateData.

private void generateData(RecordStorageEngine storageEngine, int denseThreshold, int[] relationshipTypes) throws Exception {
    int numNodes = 100;
    long[] nodes = new long[numNodes];
    applyLogicalChanges(storageEngine, (state, tx) -> {
        NodeStore nodeStore = storageEngine.testAccessNeoStores().getNodeStore();
        for (int i = 0; i < numNodes; i++) {
            nodes[i] = nodeStore.nextId(NULL);
            tx.visitCreatedNode(nodes[i]);
        }
    });
    RelationshipStore relationshipStore = storageEngine.testAccessNeoStores().getRelationshipStore();
    List<RelationshipData> relationships = new ArrayList<>();
    int numRelationships = numNodes * denseThreshold;
    for (int i = 0; i < numRelationships; i++) {
        relationships.add(new RelationshipData(relationshipStore.nextId(NULL), random.among(relationshipTypes), random.among(nodes), random.among(nodes)));
    }
    applyLogicalChanges(storageEngine, (state, tx) -> {
        NodeState nodeState = mock(NodeState.class);
        when(nodeState.labelDiffSets()).thenReturn(LongDiffSets.EMPTY);
        when(state.getNodeState(anyLong())).thenReturn(nodeState);
        tx.visitRelationshipModifications(new FlatRelationshipModifications(relationships.toArray(new RelationshipData[0])));
    });
}
Also used : RelationshipData(org.neo4j.internal.recordstorage.FlatRelationshipModifications.RelationshipData) NodeStore(org.neo4j.kernel.impl.store.NodeStore) NodeState(org.neo4j.storageengine.api.txstate.NodeState) FlatRelationshipModifications(org.neo4j.internal.recordstorage.FlatRelationshipModifications) ArrayList(java.util.ArrayList) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore)

Aggregations

ArrayList (java.util.ArrayList)1 FlatRelationshipModifications (org.neo4j.internal.recordstorage.FlatRelationshipModifications)1 RelationshipData (org.neo4j.internal.recordstorage.FlatRelationshipModifications.RelationshipData)1 NodeStore (org.neo4j.kernel.impl.store.NodeStore)1 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)1 NodeState (org.neo4j.storageengine.api.txstate.NodeState)1