Copilot commented on code in PR #3037:
URL: https://github.com/apache/hugegraph/pull/3037#discussion_r3328862340


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java:
##########
@@ -190,19 +190,17 @@ public void apply(final Traversal.Admin<?, ?> traversal) {
                         traversal.asAdmin().removeStep(curr);
                         size -= 2;
                         if (!dismissCountIs) {
-                            final TraversalParent p;
-                            if ((p = traversal.getParent()) instanceof 
FilterStep &&
-                                !(p instanceof ConnectiveStep)) {
-                                final Step<?, ?> filterStep = parent.asStep();
-                                final Traversal.Admin parentTraversal =
-                                        filterStep.getTraversal();
-                                final Step notStep = new NotStep<>(
-                                        parentTraversal,
-                                        traversal.getSteps().isEmpty() ?
-                                        __.identity() : traversal);
-                                
filterStep.getLabels().forEach(notStep::addLabel);
+                            if (parent instanceof ConnectiveStep) {
+                                final Step<?, ?> notStep = 
this.transformToNotStep(
+                                        traversal, parent);
+                                TraversalHelper.removeAllSteps(traversal);
+                                traversal.addStep(notStep);
+                            } else if (parent instanceof FilterStep) {
+                                final Step filterStep = parent.asStep();
+                                final Step<?, ?> notStep = 
this.transformToNotStep(
+                                        traversal, parent);

Review Comment:
   In the `ConnectiveStep` branch, `transformToNotStep()` builds `NotStep` 
using the *parent traversal* (`filterStep.getTraversal()`), but the step is 
then added into the *child traversal* (`traversal.addStep(notStep)`). `NotStep` 
should be constructed with the traversal it will live in (here: the child 
`traversal`) to avoid integrating the step/child traversal with the wrong 
traversal context (side-effects, parent, etc.).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to