imbajin commented on code in PR #3100:
URL: https://github.com/apache/hugegraph/pull/3100#discussion_r3625124715


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java:
##########
@@ -272,10 +272,28 @@ private boolean doStrategy(final Step step) {
             return false;
         }
 
+        final P<?> predicate = ((IsStep<?>) step.getNextStep()).getPredicate();
+        if (this.hasNestedConnectivePredicate(predicate)) {

Review Comment:
   ‼️ **Critical: flat connective predicates remain semantically unsafe**
   
   This guard only rejects a `ConnectiveP` whose child is another 
`ConnectiveP`, so flat expressions such as `P.eq(0L).and(P.gt(0L))` and 
`P.lte(0L).or(P.gte(1L))` still enter the optimization. The loop then derives 
`useNotStep` from only the first range-driving child and removes the complete 
`count().is(...)`; on an empty adjacency the contradiction can return true, and 
on a non-empty adjacency the tautology can return false. Both shapes were 
reproduced against the current strategy on TinkerPop 3.5.1. Please disable the 
destructive rewrite for every `ConnectiveP` unless equivalence is derived from 
the complete boolean expression; the conservative fix is to skip all 
`ConnectiveP` values here. Add flat AND/OR regressions for both zero and 
nonzero counts.



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