Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. User

    [Improve] Align HugeCountStrategy with upstream TINKERPOP-2911 ConnectiveStep fixes

    Feature Description (功能描述)

    Background

    PR #2993 introduced HugeCountStrategy to fix the negative-bound optimization issues behind #2930, #2931, and #2932.

    That fix was implemented by forking an older version of TinkerPop's CountStrategy and 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 from TINKERPOP-2911.

    As a result, HugeGraph is now aligned for the negative-bound cases fixed in #2993, but it may still inherit older CountStrategy behavior for some connective-filter patterns.

    Follow-up Scope

    Port the upstream TINKERPOP-2911 changes for ConnectiveStep into HugeCountStrategy, 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

    • HugeCountStrategy should behave consistently with the upstream CountStrategy fixes around ConnectiveStep
    • 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.

  2. Assistant

    TinkerPop 3.5.1. Now let me get the upstream CountStrategy with the TINKERPOP-2911 fix to compare. Let me check network access:

  3. Assistant

    Now add the transformToNotStep helper before doStrategy:

  4. Assistant

    The core change is in. Now let me check the upstream test cases for TINKERPOP-2911 to model regression expectations correctly:

  5. Assistant

    Let me check how the strategy is registered in HugeGraph.java:

  6. Assistant

    Registration is fine. Now compile hugegraph-core:

  7. Assistant

    Generics capture issue — upstream uses a raw Step here. Fix to match:

  8. Assistant

    Compiles. Now add the regression tests. First check BaseCoreTest setup to run tests correctly:

  9. Assistant

    Now add the regression tests to CountStrategyCoreTest:

  10. Assistant

    Add the needed imports:

  11. Assistant

    CoreTestSuite.graph() initializes lazily, so I can run the test class directly. Run it (memory backend):

  12. Assistant

    The -Dtest filter breaks upstream modules with no matching tests. Retry with -DfailIfNoTests=false:

  13. Assistant

    While that runs, let me verify strategy interplay with HugeCountStepStrategy (whether it could consume the CountGlobalStep first):

  14. Assistant

    The build failed quickly — likely a compile error in the test module. Rerun capturing full errors:

  15. Assistant

    Without -am the reactor deps can't resolve offline. Rerun with -am and capture errors:

  16. Assistant

    While waiting, let me double-check commitTx() exists in BaseCoreTest:

  17. Assistant

    Good. Now waiting for the build result.

  18. Assistant

    The build is progressing through module compilation. I'll wait for the completion notification.

  19. Assistant

    Compilation succeeded; the failure is just a missing surefire provider jar in offline mode. Network to GitHub worked earlier — try downloading it:

  20. Assistant

    I'll wait for the completion notification.

  21. Assistant

    Tests look right. Rerun:

  22. Assistant

    Waiting for the run to finish.

  23. 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:

  24. Assistant

    Waiting for this verification run.

  25. Assistant

    Waiting for the final confirmation run.

  26. Assistant

    The diff is a faithful port of the upstream change. Waiting on the EdgeCoreTest safety-net run.

  27. Assistant

    All green. The task is complete.

    Summary

    Ported the upstream TINKERPOP-2911 ConnectiveStep fixes into HugeCountStrategy and added regression coverage.

    Strategy change — HugeCountStrategy.java

    • ConnectiveStep handling (hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeCountStrategy.java:193): when a count().is(...) pattern sits in a child of and()/or(), the child traversal itself is now rewritten in place to not(<child>). The old forked code fell through to the prev-based path, which rewrote e.g. or(out("knows").out().count().is(0), ...) to out("knows").not(out()) — leaving the leading step outside the not() and changing semantics (wrong for vertices where out("knows") is empty, or where only some intermediate vertices have further edges).
    • transformToNotStep helper (HugeCountStrategy.java:274): ported verbatim from upstream — builds the NotStep, clones the child traversal, and copies the filter step's labels; shared by both the ConnectiveStep and plain FilterStep branches.
    • HugeGraph-specific guards from #2993 (negative-bound useNotStep/dismissCountIs suppression and the highRange < 0 → skip optimization backend-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 edges
    • testWhereOrMultiHopCountIsZeroWithHasFilter — where(or(out("knows").out().count().is(0), has(...)))
    • testWhereOrMultiHopBothChildrenCountIsZero — both or() children ending in count().is(0)
    • testConnectiveCountIsZeroRewrittenToNotStep — structural assertion that after applyStrategies() the or() children contain 2 NotSteps and zero CountGlobalSteps

    (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 (0 vs 2, 2 vs 3), proving the tests catch drift from upstream; the fix was then re-applied.
    • EdgeCoreTest as a broader safety net: 168 run, 0 failures.

    Note: the pom.xml modification in the working tree (lombok/compiler-plugin versions) predates this task and was left untouched.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.