fix(core): align count strategy connective steps#3037
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3037 +/- ##
============================================
- Coverage 35.85% 29.70% -6.16%
+ Complexity 338 264 -74
============================================
Files 802 803 +1
Lines 67995 68060 +65
Branches 8902 8908 +6
============================================
- Hits 24381 20216 -4165
- Misses 41008 45526 +4518
+ Partials 2606 2318 -288 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates HugeGraph’s local HugeCountStrategy (a fork of TinkerPop’s CountStrategy) to handle ConnectiveStep (and() / or()) cases consistently with upstream TINKERPOP-2911 behavior, and adds regression tests to prevent drift.
Changes:
- Adjust
HugeCountStrategyto rewrite connective child traversals when convertingcount().is(0)patterns intonot(...). - Introduce a helper to build
NotStepwith a cloned traversal (so the whole child traversal is wrapped, not just its tail). - Add regression tests covering
and()/or()andwhere(or(...))multi-step shapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java | Updates count().is(0) rewrite logic to better handle ConnectiveStep traversals and centralizes NotStep creation. |
| hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CountStrategyCoreTest.java | Adds schema support and new regression tests for connective and multi-step or() traversal shapes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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); |
Purpose of the PR
PR #2993 introduced
HugeCountStrategyto guard HugeGraph against unsafe negative-boundcount().is(P)optimizations.This follow-up ports the upstream TINKERPOP-2911
ConnectiveStephandling into HugeGraph's local strategy, soand()/or()child traversals are rewritten consistently with upstreamCountStrategy.Main Changes
ConnectiveStepseparately when convertingcount().is(0)intonot(...)not(...)using a cloned traversal, instead of only rewriting the tail stepFilterStepconversionand()/or()traversal shapes, including multi-stepwhere(or(...))casesVerifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need