Skip to content

fix(core): align count strategy connective steps#3037

Open
contrueCT wants to merge 1 commit into
apache:masterfrom
contrueCT:task/issue-2995-count-strategy
Open

fix(core): align count strategy connective steps#3037
contrueCT wants to merge 1 commit into
apache:masterfrom
contrueCT:task/issue-2995-count-strategy

Conversation

@contrueCT
Copy link
Copy Markdown
Contributor

Purpose of the PR

PR #2993 introduced HugeCountStrategy to guard HugeGraph against unsafe negative-bound count().is(P) optimizations.

This follow-up ports the upstream TINKERPOP-2911 ConnectiveStep handling into HugeGraph's local strategy, so and() / or() child traversals are rewritten consistently with upstream CountStrategy.

Main Changes

  • Handle ConnectiveStep separately when converting count().is(0) into not(...)
  • Wrap the whole child traversal in not(...) using a cloned traversal, instead of only rewriting the tail step
  • Reuse the same helper for FilterStep conversion
  • Keep the existing negative-bound safeguards from PR fix(server): guard count strategy on negative bounds #2993 unchanged
  • Add regression coverage for connective and() / or() traversal shapes, including multi-step where(or(...)) cases

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. tests Add or improve test cases labels May 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.58%. Comparing base (1f61c48) to head (5f7a01c).

Files with missing lines Patch % Lines
...ugegraph/traversal/optimize/HugeCountStrategy.java 57.14% 4 Missing and 2 partials ⚠️

❗ There is a different number of reports uploaded between BASE (1f61c48) and HEAD (5f7a01c). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (1f61c48) HEAD (5f7a01c)
3 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3037      +/-   ##
============================================
- Coverage     36.11%   29.58%   -6.53%     
+ Complexity      338      264      -74     
============================================
  Files           803      803              
  Lines         68234    68241       +7     
  Branches       8964     8965       +1     
============================================
- Hits          24640    20192    -4448     
- Misses        40936    45696    +4760     
+ Partials       2658     2353     -305     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HugeCountStrategy to rewrite connective child traversals when converting count().is(0) patterns into not(...).
  • Introduce a helper to build NotStep with a cloned traversal (so the whole child traversal is wrapped, not just its tail).
  • Add regression tests covering and() / or() and where(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.

@contrueCT contrueCT force-pushed the task/issue-2995-count-strategy branch from b47943f to 5f7a01c Compare June 5, 2026 12:27
@contrueCT
Copy link
Copy Markdown
Contributor Author

@imbajin I think this PR is ready to merge. It looks like the Codecov uploads were incomplete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files. tests Add or improve test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants