Skip to content

Commit 6b54060

Browse files
s1ckDarthMax
andcommitted
Use constant in RelationshipsBatchBuffer for elements per entity
Co-Authored-By: Max Kießling <[email protected]>
1 parent b4eaedc commit 6b54060

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

core/src/main/java/org/neo4j/gds/core/loading/RelationshipsBatchBuffer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
public final class RelationshipsBatchBuffer extends RecordsBatchBuffer<RelationshipReference> {
3131

32+
// For relationships, the buffer is divided into 2-long blocks
33+
// for each relationship: source, target. Relationship and
34+
// property references are stored individually.
35+
public static final int ENTRIES_PER_RELATIONSHIP = 2;
36+
3237
private final PartialIdMap idMap;
3338
private final int type;
3439
private final boolean throwOnUnMappedNodeIds;
@@ -55,9 +60,7 @@ public RelationshipsBatchBuffer(
5560
int capacity,
5661
boolean throwOnUnMappedNodeIds
5762
) {
58-
// For relationships: the buffer is divided into 4-long blocks
59-
// for each rel: source, target, rel-id, prop-id
60-
super(Math.multiplyExact(2, capacity));
63+
super(Math.multiplyExact(ENTRIES_PER_RELATIONSHIP, capacity));
6164
this.idMap = idMap;
6265
this.type = type;
6366
this.throwOnUnMappedNodeIds = throwOnUnMappedNodeIds;

core/src/main/java/org/neo4j/gds/core/loading/ThreadLocalSingleTypeRelationshipImporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public long importRelationships() {
183183
long[][] outProperties = propertyReader.readProperty(
184184
sourceBuffer().relationshipReferences(),
185185
sourceBuffer().propertyReferences(),
186-
batchLength / 2,
186+
batchLength / RelationshipsBatchBuffer.ENTRIES_PER_RELATIONSHIP,
187187
targetBuffer().getPropertyKeyIds(),
188188
targetBuffer().getDefaultValues(),
189189
targetBuffer().getAggregations(),
@@ -195,7 +195,7 @@ public long importRelationships() {
195195
long[][] inProperties = propertyReader.readProperty(
196196
sourceBuffer().relationshipReferences(),
197197
sourceBuffer().propertyReferences(),
198-
batchLength / 2,
198+
batchLength / RelationshipsBatchBuffer.ENTRIES_PER_RELATIONSHIP,
199199
targetBuffer().getPropertyKeyIds(),
200200
targetBuffer().getDefaultValues(),
201201
targetBuffer().getAggregations(),

0 commit comments

Comments
 (0)