Skip to content

Commit

Permalink
Implement visitAllCounts
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentinD authored and Mats-SX committed Dec 5, 2023
1 parent 6413880 commit 0bc8322
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.neo4j.common.TokenNameLookup;
import org.neo4j.counts.CountsStore;
import org.neo4j.counts.CountsVisitor;
import org.neo4j.gds.NodeLabel;
import org.neo4j.gds.RelationshipType;
import org.neo4j.gds.compat._515.InMemoryNodeCursor;
import org.neo4j.gds.compat._515.InMemoryPropertyCursor;
import org.neo4j.gds.compat._515.InMemoryRelationshipScanCursor;
Expand Down Expand Up @@ -340,4 +342,22 @@ public TokenNameLookup tokenNameLookup() {
return tokenHolders;
}

@Override
public void visitAllCounts(CountsVisitor countsVisitor, CursorContext cursorContext) {
for (NodeLabel label : graphStore.nodeLabels()) {
var tokenHolder = tokenHolders.labelTokens();
countsVisitor.visitNodeCount(tokenHolder.getIdByName(label.name()), graphStore.nodes().nodeCount(label));
}

for (RelationshipType relationshipType : graphStore.relationshipTypes()) {
var tokenHolder = tokenHolders.relationshipTypeTokens();
// we dont know start / end label for a reltype
countsVisitor.visitRelationshipCount(
-1,
tokenHolder.getIdByName(relationshipType.name()),
-1,
graphStore.relationshipCount(relationshipType)
);
}
}
}

0 comments on commit 0bc8322

Please sign in to comment.