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
Let me look at the context: the TinkerPop version in use, the original PR #2993 changes, and any existing tests.
- Assistant
Now add the
transformToNotStephelper: - Assistant
Now let me compile the core module:
- Assistant
Now let me check how
HugeVertex.property()handles a property key that exists in schema but isn't defined on the vertex label, since the regression tests usehas("none")/out("none"): - Assistant
Now let's find how to run the core tests:
- Assistant
While that runs, let me review the final state of
HugeCountStrategy: - Assistant
The offline run failed on dependency resolution. Let me check what
hugegraph-structis and build the full reactor path: - Assistant
While tests run, let me double-check the diff of the strategy against upstream to confirm only intentional deviations remain:
- Assistant
Diff looks faithful to upstream. Waiting for test results:
- Assistant
The test run is in progress (building the reactor with
-amtakes a few minutes). I'll report when it completes. - Assistant
Waiting on the build — the monitor will notify when it finishes.
- Assistant
commitTx()is available in the base class. Now waiting for the test run to complete. - Assistant
All 23 tests pass (19 existing + 4 new). Now let me verify the new tests actually discriminate — i.e., they fail with the pre-fix strategy:
- Assistant
Both TINKERPOP-2911 regression tests fail against the pre-fix strategy and pass with the fix — exactly the discrimination we wanted. The fix is restored. Work is complete:
Summary
Ported upstream TINKERPOP-2911
ConnectiveStepfixes intoHugeCountStrategy(hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java):ConnectiveStepparents get their own branch (): when a -style child sits inside /, the is wrapped in in place ( + + ). The old forked code fell into the -based branch, which produced instead of — semantically wrong, since of an empty stream is (true) while a filter on an empty stream is false.
- Assistant
That's the completion notice for the pre-fix verification run I already analyzed — no new action needed. Final state stands:
HugeCountStrategynow matches upstreamCountStrategypost-TINKERPOP-2911 forConnectiveStephandling (with the #2993 negative-bound guards preserved).- 4 new regression tests in
CountStrategyCoreTest: all 23 tests pass with the fix; the twowhere(or(...))tests fail without it, confirming they guard against drift. - Working tree contains the two intended modified files (plus the pre-existing
pom.xmllombok/compiler change that was already there before I started — I left it untouched).
- Assistant
That's a second chunk of the same pre-fix verification output (the
core-testprofile adds a second surefire execution, so the class ran twice in that mvn invocation). Reading the full picture of the pre-fix run:- Execution 1:
Failures: 2— bothtestWhereOrPrefixedCountIsZeroWithHasClauseandtestWhereOrPrefixedCountIsZeroWithHasCountClausefail - Execution 2:
Failures: 1—testWhereOrPrefixedCountIsZeroWithHasClausefails - Overall:
BUILD FAILURE
This is consistent with the analysis: under the old strategy, the 4th shape (
or(out("none").out().count().is(0), has("none").count().is(0))) can partially "rescue" itself because its second clause transforms tonot(has("none"))(which is semantically fine), making it state-dependent pre-fix — while the 3rd shape (or(..., has("none"))) fails deterministically in both executions. So the suite reliably breaks against the old behavior.Nothing to change — final state remains:
- With the fix (current working tree):
Tests run: 23, Failures: 0—
- Execution 1:
- Assistant
All background monitors have wrapped up — nothing further to act on. The task is complete:
Changes:
hugegraph-server/hugegraph-core/.../traversal/optimize/HugeCountStrategy.java— ported the upstream TINKERPOP-2911ConnectiveStephandling:and()/or()children withcount().is(...)are now wrapped innot()in place via the newtransformToNotStephelper (withtraversal.clone(), matching upstream), while plainFilterStepparents keep the whole-filter →not()conversion. The #2993 negative-bound guards are untouched.hugegraph-server/hugegraph-test/.../core/CountStrategyCoreTest.java— 4 regression tests covering exactly the traversal shapes from the issue, plus a schema-defined empty"none"edge label so the shapes are valid in HugeGraph.
Verification:
- Fixed code:
Tests run: 23, Failures: 0— BUILD SUCCESS (memory backend,core-testprofile) - Pre-fix code (stashed, re-run, restored): BUILD FAILURE with the
where(or(...))regression tests failing — confirming the tests protect against drift back to the forked behavior
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.