chore: Batch fetch Owns/WriteOwner - BED-8364#2823
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR changes postOwnsEdges and postWriteOwnerEdges to deduplicate relationship EndIDs, bulk-fetch all referenced target nodes via FetchNodeSet, resolve targets from the returned NodeSet, and log+skip relationships whose target is absent; a new collectUniqueEndIDs helper was added. Enforcement and gating checks are unchanged. ChangesBulk node fetching optimization
Sequence DiagramsequenceDiagram
participant postOwnsEdges
participant postWriteOwnerEdges
participant collectUniqueEndIDs
participant FetchNodeSet
participant NodeSet
participant submitEdge
postOwnsEdges->>collectUniqueEndIDs: collect EndIDs from relationships
postWriteOwnerEdges->>collectUniqueEndIDs: collect EndIDs from relationships
collectUniqueEndIDs->>FetchNodeSet: FetchNodeSet(InIDs = unique EndIDs)
FetchNodeSet->>NodeSet: return NodeSet
postOwnsEdges->>NodeSet: lookup target by EndID
postOwnsEdges->>submitEdge: submit Owns edge (if target found & gating)
postWriteOwnerEdges->>NodeSet: lookup target by EndID
postWriteOwnerEdges->>submitEdge: submit WriteOwner edge (if target found & gating)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/go/analysis/ad/owns.go (1)
252-263: 💤 Low valueConsider a richer variable name for
ids.Per coding guidelines, prefer rich variable names. Consider renaming
idstouniqueEndIDsorendIDsto make the intent clearer.♻️ Proposed refactor
func collectUniqueEndIDs(relationships []*graph.Relationship) []graph.ID { seen := make(map[graph.ID]struct{}, len(relationships)) - ids := make([]graph.ID, 0, len(relationships)) + uniqueEndIDs := make([]graph.ID, 0, len(relationships)) for _, rel := range relationships { if _, ok := seen[rel.EndID]; !ok { seen[rel.EndID] = struct{}{} - ids = append(ids, rel.EndID) + uniqueEndIDs = append(uniqueEndIDs, rel.EndID) } } - return ids + return uniqueEndIDs }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/go/analysis/ad/owns.go` around lines 252 - 263, In collectUniqueEndIDs, rename the local slice variable ids to a clearer name (e.g., uniqueEndIDs or endIDs) to follow naming guidelines and make the intent explicit; update its declaration and all usages inside the function (the append and the returned value) so the function still returns the same []graph.ID but with the clearer identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/go/analysis/ad/owns.go`:
- Around line 252-263: In collectUniqueEndIDs, rename the local slice variable
ids to a clearer name (e.g., uniqueEndIDs or endIDs) to follow naming guidelines
and make the intent explicit; update its declaration and all usages inside the
function (the append and the returned value) so the function still returns the
same []graph.ID but with the clearer identifier.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 18b8bff1-83cb-40ce-9b98-8a14ede73fc1
📒 Files selected for processing (1)
packages/go/analysis/ad/owns.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/go/analysis/ad/owns.go`:
- Around line 253-254: Group the local variable declarations into a var (...)
block hoisted near the top of the function and rename uniqueEndIds to
uniqueEndIDs to follow Go acronym-casing conventions; specifically replace the
separate statements creating seen := make(map[graph.ID]struct{},
len(relationships)) and uniqueEndIds := make([]graph.ID, 0, len(relationships))
with a var block declaring seen and uniqueEndIDs, then update all references
(e.g., where you compare to rel.EndID) to use uniqueEndIDs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 785f2aeb-f07f-4f9a-ab60-842abe204b98
📒 Files selected for processing (1)
packages/go/analysis/ad/owns.go
Description
During Owns/WriteOwner post-processing, batch-fetch all unique target node IDs into a graph.NodeSet via a single ops.FetchNodeSet query with InIDs before entering the relationship loop. Each iteration then does a local map lookup instead of a DB round-trip. In tested datasets, this change yielded approximately 50% reduction in post-processing duration for these edges.
Motivation and Context
Resolves BED-8364
Why is this change required? What problem does it solve?
How Has This Been Tested?
No changes have been made to existing test suites. Additionally, validated locally with several datasets.
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit
Performance
Bug Fixes