Skip to content

Conversation

@javeme
Copy link
Contributor

@javeme javeme commented Aug 30, 2025

Change-Id: Ie7169fdb707495ff0a298ea97fa4d105117a132d

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Aug 30, 2025
@javeme javeme requested review from VGalaxies, imbajin and zyxxoo August 30, 2025 20:15
@dosubot dosubot bot added the perf label Aug 30, 2025
Change-Id: Ie7169fdb707495ff0a298ea97fa4d105117a132d
@javeme javeme force-pushed the AdjacentEdgesQuery branch from 804208a to 7633d86 Compare August 30, 2025 20:33
@imbajin imbajin requested a review from Copilot September 1, 2025 08:38
Copy link
Contributor

Copilot AI left a 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 AdjacentEdgesQuery class 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.

Comment on lines +1309 to 1311
if (true) {
return new AdjacentEdgesQuery(sourceVertex, direction, edgeLabels);
}
Copy link

Copilot AI Sep 1, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +464 to +465
if (this.conditions.isEmpty()) {
// UnsupprotedOperationException when ImmutableList.removeIf()
Copy link

Copilot AI Sep 1, 2025

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'.

Suggested change
if (this.conditions.isEmpty()) {
// UnsupprotedOperationException when ImmutableList.removeIf()
// UnsupportedOperationException when ImmutableList.removeIf()

Copilot uses AI. Check for mistakes.

public AdjacentEdgesQuery(Id ownerVertex, Directions direction,
Id[] edgeLabels) {
super(HugeType.EDGE);
Copy link
Member

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;
}
Copy link
Member

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;
}
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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);
}

Copy link
Member

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.

@github-actions
Copy link

github-actions bot commented Oct 1, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inactive perf size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants