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


##########
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:
   Thanks for the review. This implementation intentionally mirrors upstream 
TinkerPop CountStrategy after TINKERPOP-2911. The upstream helper also 
constructs NotStep with parent.asStep().getTraversal(), and the ConnectiveStep 
branch then inserts it into the child traversal. During insertion, 
DefaultTraversal.addStep() calls step.setTraversal(this), and 
NotStep.setTraversal() reintegrates its child traversal, so the step is rebound 
to the traversal it lives in. I don't think changing this to construct with the 
child traversal is appropriate for this follow-up.



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