ISSUE DESCRIPTION [Improve] Align HugeCountStrategy with upstream TINKERPOP-2911…
- User
ISSUE DESCRIPTION
[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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. Assistant
Found PR #2016. Let's fetch the diff.
Assistant
Now I have the exact upstream diff. Let's apply the equivalent change to HugeCountStrategy.java.
Assistant
Now let's replace lines 192-235 with the upstream-aligned logic, and add the helper method after the apply method.
Assistant
I'll use the
replacespecial command instead.Assistant
Now let's add the
transformToNotStephelper method after theapplymethod (beforedoStrategy).Assistant
Good,
removeAllStepsexists. Now let's checkTraversal.Admin.clone()exists too (should, standard interface method). Let's build the project.Assistant
Good, that succeeded. Now let's try building hugegraph-core.
Assistant
It compiled successfully (only warnings). Now let's compile the test class too and run the existing CountStrategyCoreTest.
Assistant
Let's create a small script to reproduce the traversal-shape regression test using JUnit-less standalone Java, using the maven dependency classpath.
Assistant
Now let's write a small standalone Java test file to reproduce the regression scenarios and verify strategy behavior.
Assistant
Compiled. Let's run it.
Assistant
All pass. Let's verify against the pre-patch version to confirm the fix actually matters (i.e., some cases would fail without it).
Assistant
All fixed cases now pass with the new code. Now let's add regression tests in
CountStrategyCoreTest.javacovering the connective traversal shapes mentioned in the issue.Assistant
Let's try running the existing test class with the memory backend to see baseline works, before adding new tests.
Assistant
Now let's try running the test module directly without -am.
Assistant
All required modules installed (skip tests avoided the pd test failure). Now let's run the test directly on hugegraph-test without
-am.Assistant
All 19 existing tests pass. Now let's add regression tests for the connective traversal shapes.
Assistant
Now let's insert a schema/graph helper and the four regression tests, using the
initSchema()/initGraph()fixture (marko, josh, lop) plus an isolated vertex, and a "none" property key.Assistant
Need a blank line before the next
@Test.Assistant
Now let's compile and run the test suite.
Assistant
Compiles fine. Now let's run the tests.
Assistant
Now let's rerun the tests.
Assistant
All 23 tests (19 existing + 4 new) pass. Let's also verify the fix actually breaks (or at least changes) old-code behavior for these new functional tests, to prove regression coverage is meaningful.
Assistant
Now let's update
testWhereOrConnectiveWithHasCountKeepsSemanticsto add an extra vertex with the "none" property set, and adjust expected counts.Assistant
Extra closing brace at line 294. Let's fix.
Assistant
Now let's verify with the fixed strategy (rebuild hugegraph-core with our fix and reinstall).
Assistant
All pass with the fix. Now let's confirm this new test fails without the fix.
Assistant
Both new regression tests now correctly fail without the fix, and pass with it. Let's restore our fix.
Assistant
Now let's run the full CoreTestSuite relevant subset (at least the whole hugegraph-core test package) to make sure nothing else broke, plus rerun target tests to confirm final state.
Assistant
All pass. Let's also double check final diff of
HugeCountStrategy.javafor correctness/style.Assistant
This matches upstream's fix closely, adapted to HugeGraph's code style. Let's do a final full review of the diff and the compile check.
Assistant
This looks good. Let's clean up temporary scratch files and do a final full test run for the whole test class to be safe, then check checkstyle compliance.
Assistant
checkstyle passes cleanly for hugegraph-core (including our modified file). Let's also check the test module for checkstyle compliance.
Assistant
Both pass checkstyle. Now let's run the full CountStrategyCoreTest one more time as a final sanity check.
Assistant
All good. Let's review the final diff once more before submitting.
Assistant
This is a pre-existing environment-setup change (lombok/JDK compatibility) that was already present before I started — unrelated to this issue, so I'll leave it untouched. Now let's go through the checklist explicitly before submitting.
Assistant
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. Yes — I retrieved the exact upstream TinkerPop PR (#2016, TINKERPOP-2911) that this issue asks to port, and wrote a standalone harness applying
HugeCountStrategyto the traversal shapes named in the issue (and(out().count().is(0), in().count().is(0)),or(...),where(or(out("none").out().count().is(0), has("none"))),where(or(..., has("none").count().is(0)))). With the original (pre-fix)HugeCountStrategy, the step-shape harness showed clearFAILresults for the nestedout().out()andwhere(or(...))cases, confirming the inherited bug from the old forkedCountStrategy. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes — after porting the upstream fix (splitting
ConnectiveStephandling from genericFilterStephandling, and cloning the inner traversal via a new helper), all shapes in the harness now , and the two new functional regression tests I added (, ) fail against the old code and pass against the fixed code, which I verified by toggling the change via .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.