Untitled conversation
- User
[Improve] Align HugeCountStrategy with upstream TINKERPOP-2911 ConnectiveStep fixes
Feature Description (功能描述)
Background
PR #2993 introduced
HugeCountStrategyto fix the negative-bound optimization issues behind #2930, #2931, and #2932.That fix was implemented by forking an older version of TinkerPop's
CountStrategyand adding HugeGraph-specific guards for negative bounds.However, the current local fork does not yet include the upstream follow-up fix for
ConnectiveStep/and()/or()handling fromTINKERPOP-2911.As a result, HugeGraph is now aligned for the negative-bound cases fixed in #2993, but it may still inherit older
CountStrategybehavior for some connective-filter patterns.Follow-up Scope
Port the upstream
TINKERPOP-2911changes forConnectiveStepintoHugeCountStrategy, and add regression coverage for connective traversal shapes.Suggested regression cases include:
__.and(__.out().count().is(0), __.in().count().is(0))__.or(__.out().count().is(0), __.in().count().is(0))__.where(__.or(__.out("none").out().count().is(0), __.has("none")))__.where(__.or(__.out("none").out().count().is(0), __.has("none").count().is(0)))
Expected Result
HugeCountStrategyshould behave consistently with the upstreamCountStrategyfixes aroundConnectiveStep- connective
and()/or()traversal shapes should no longer rely on older inherited behavior from the forked strategy - regression tests should cover the above traversal forms and protect against future drift
I’d be happy to follow up on this as a separate improvement issue and work on a later refinement PR.
Interface
No new interfaces are introduced.
- Assistant
TinkerPop 3.5.1. Now let me get the upstream
CountStrategywith the TINKERPOP-2911 fix to compare. Let me check network access: - Assistant
Now add the
transformToNotStephelper beforedoStrategy: - Assistant
The core change is in. Now let me check the upstream test cases for TINKERPOP-2911 to model regression expectations correctly:
- Assistant
Let me check how the strategy is registered in HugeGraph.java:
- Assistant
Registration is fine. Now compile hugegraph-core:
- Assistant
Generics capture issue — upstream uses a raw
Stephere. Fix to match: - Assistant
Compiles. Now add the regression tests. First check
BaseCoreTestsetup to run tests correctly: - Assistant
Now add the regression tests to
CountStrategyCoreTest: - Assistant
Add the needed imports:
- Assistant
CoreTestSuite.graph()initializes lazily, so I can run the test class directly. Run it (memory backend): - Assistant
The
-Dtestfilter breaks upstream modules with no matching tests. Retry with-DfailIfNoTests=false: - Assistant
While that runs, let me verify strategy interplay with
HugeCountStepStrategy(whether it could consume theCountGlobalStepfirst): - Assistant
The build failed quickly — likely a compile error in the test module. Rerun capturing full errors:
- Assistant
Without
-amthe reactor deps can't resolve offline. Rerun with-amand capture errors: - Assistant
While waiting, let me double-check
commitTx()exists inBaseCoreTest: - Assistant
Good. Now waiting for the build result.
- Assistant
The build is progressing through module compilation. I'll wait for the completion notification.
- Assistant
Compilation succeeded; the failure is just a missing surefire provider jar in offline mode. Network to GitHub worked earlier — try downloading it:
- Assistant
I'll wait for the completion notification.
- Assistant
Tests look right. Rerun:
- Assistant
Waiting for the run to finish.
- Assistant
All 24 tests pass. Now let me verify the new tests actually catch the old behavior — temporarily revert the strategy fix and confirm they fail:
- Assistant
Waiting for this verification run.
- Assistant
Waiting for the final confirmation run.
- Assistant
The diff is a faithful port of the upstream change. Waiting on the
EdgeCoreTestsafety-net run. - Assistant
All green. The task is complete.
Summary
Ported the upstream TINKERPOP-2911
ConnectiveStepfixes intoHugeCountStrategyand added regression coverage.Strategy change —
HugeCountStrategy.javaConnectiveStephandling (hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java:193): when acount().is(...)pattern sits in a child ofand()/or(), the child traversal itself is now rewritten in place tonot(<child>). The old forked code fell through to theprev-based path, which rewrote e.g.or(out("knows").out().count().is(0), ...)toout("knows").not(out())— leaving the leading step outside thenot()and changing semantics (wrong for vertices whereout("knows")is empty, or where only some intermediate vertices have further edges).transformToNotStephelper (HugeCountStrategy.java:274): ported verbatim from upstream — builds theNotStep, clones the child traversal, and copies the filter step's labels; shared by both theConnectiveStepand plainFilterStepbranches.- HugeGraph-specific guards from #2993 (negative-bound
useNotStep/dismissCountIssuppression and thehighRange < 0 → skip optimizationbackend-range guard) are preserved unchanged.
Regression tests —
CountStrategyCoreTest.java(5 new, matching the shapes in the issue)testAndConnectiveCountIsZero—and(out().count().is(0), in().count().is(0))testOrConnectiveCountIsZero—or(...)variant with a vertex having both in and out edgestestWhereOrMultiHopCountIsZeroWithHasFilter—where(or(out("knows").out().count().is(0), has(...)))testWhereOrMultiHopBothChildrenCountIsZero— bothor()children ending incount().is(0)testConnectiveCountIsZeroRewrittenToNotStep— structural assertion that afterapplyStrategies()theor()children contain 2NotSteps and zeroCountGlobalSteps
(I used defined labels/keys —
knows,name— instead of the issue's literal"none", since HugeGraph rejects undefined schema elements in traversals; the shapes are structurally identical.)Verification
CountStrategyCoreTest(memory backend): 24/24 pass with the fix.- Reverting only the strategy fix makes the two multi-hop
where(or(...))tests fail exactly as expected (0vs2,2vs3), proving the tests catch drift from upstream; the fix was then re-applied. EdgeCoreTestas a broader safety net: 168 run, 0 failures.
Note: the
pom.xmlmodification in the working tree (lombok/compiler-plugin versions) predates this task and was left untouched.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →