-
Notifications
You must be signed in to change notification settings - Fork 566
perf(core): add AdjacentEdgesQuery #2864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Change-Id: Ie7169fdb707495ff0a298ea97fa4d105117a132d
804208a to
7633d86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a performance optimization by adding the AdjacentEdgesQuery class to improve edge querying for adjacent vertices. The change refactors the existing condition-based edge querying to use a more specialized and optimized query implementation.
Key changes:
- Introduces the new
AdjacentEdgesQueryclass with specialized query handling for edge traversal - Refactors method signatures to consistently use
Id[]instead of mixed array/list types - Updates query construction to utilize the new specialized query type when appropriate
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| AdjacentEdgesQuery.java | New specialized query class for optimized adjacent edge queries |
| GraphTransaction.java | Updated query construction logic to use AdjacentEdgesQuery and simplified method signatures |
| ConditionQuery.java | Added flatten capability interface and improved query relation handling |
| ConditionQueryFlatten.java | Enhanced flattening logic with better condition handling |
| Condition.java | Changed return types from Condition to Relation for better type safety |
| HugeVertexStep.java | Updated to use mapElName2Id instead of mapElName2El |
| HugeTraverser.java | Simplified array conversion in edge query construction |
| EdgesQueryIterator.java | Removed unnecessary array conversion |
| PerfExampleBase.java | Simplified edge query construction using new GraphTransaction method |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (true) { | ||
| return new AdjacentEdgesQuery(sourceVertex, direction, edgeLabels); | ||
| } |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded if (true) condition is unclear and should be replaced with a meaningful condition or removed entirely if the new AdjacentEdgesQuery should always be used.
| if (this.conditions.isEmpty()) { | ||
| // UnsupprotedOperationException when ImmutableList.removeIf() |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the comment: 'UnsupprotedOperationException' should be 'UnsupportedOperationException'.
| if (this.conditions.isEmpty()) { | |
| // UnsupprotedOperationException when ImmutableList.removeIf() | |
| // UnsupportedOperationException when ImmutableList.removeIf() |
|
|
||
| public AdjacentEdgesQuery(Id ownerVertex, Directions direction, | ||
| Id[] edgeLabels) { | ||
| super(HugeType.EDGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding defensive null check for 'ownerVertex' before using it in toString() and other methods to prevent potential NPE.
| } | ||
| if (key == HugeKeys.DIRECTION) { | ||
| return (T) this.direction; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in selfCondition() at line 186 should return an array for consistency when edgeLabels.length > 1, or throw the exception immediately instead of having an unreachable return statement.
| } | ||
| if (this.edgeLabels.length > 1) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using Collections.emptyList() instead of creating a new ArrayList when no flattening is needed for better memory efficiency.
| } | ||
|
|
||
| public static Condition in(HugeKeys key, List<?> value) { | ||
| public static Relation in(HugeKeys key, List<?> value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type changes from Condition to Relation break API compatibility. Ensure all calling code has been updated to handle Relation instead of Condition.
| Arrays.stream(edgeLabels) | ||
| .map(SchemaElement::id) | ||
| .collect(Collectors.toList()))); | ||
| if (true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded 'if (true)' should be replaced with a proper condition or configuration flag. This looks like debug/test code that should not be merged.
| if (true) { | ||
| return new AdjacentEdgesQuery(sourceVertex, direction, edgeLabels); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unreachable code after 'if (true)' block should be removed to avoid confusion and maintain code cleanliness.
|
Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label |
Change-Id: Ie7169fdb707495ff0a298ea97fa4d105117a132d