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
Let me start by exploring the repository structure and finding the relevant files.
Assistant
Now let me look at the upstream TinkerPop CountStrategy to understand what TINKERPOP-2911 changes look like. Let me first check what version of TinkerPop is being used and look at the upstream CountStrategy source if available.
Assistant
Now let me understand the upstream TINKERPOP-2911 fix. Let me look at the TinkerPop source available in the dependencies.
Assistant
Let me look at the upstream CountStrategy source to understand TINKERPOP-2911. Let me check if there's a source jar available or look at the newer version.
Assistant
Let me decompile the full CountStrategy to understand what the bundled version does:
Assistant
Let me look at the git history for the HugeCountStrategy to understand the fork:
Assistant
Let me try to get the actual upstream CountStrategy source from a newer TinkerPop version that includes TINKERPOP-2911:
Assistant
I have internet access. Let me download the CountStrategy from a newer TinkerPop version that includes TINKERPOP-2911:
Assistant
Now let me get the newer TinkerPop version that includes TINKERPOP-2911:
Assistant
Now I understand the differences. Let me compare the key sections. The TINKERPOP-2911 fix adds a dedicated
ConnectiveStepbranch in the!dismissCountIsblock and atransformToNotStephelper. Let me verify the available TinkerPop API methods:Assistant
Let me look at the test infrastructure and how tests are run:
Assistant
Let me understand the build system and try to run existing tests:
Assistant
Let me try to compile the core module first to ensure the build works:
Assistant
The core compiles. Now let me create a temporary reproduction test. First, let me check how tests are run with the test configuration:
Assistant
Let me try running an existing test to verify the test environment works:
Assistant
There's a JaCoCo issue with the JDK version (major version 69 = JDK 25). Let me check the Java version and try to disable JaCoCo. Let me check the test result - did it pass? The output is truncated. Let me check if the test passed or failed.
Assistant
There's a JaCoCo issue with the JDK version (major version 69 = JDK 25). Let me check the Java version and try to disable JaCoCo. Let me check the test result - did it pass? The output is truncated. Let me check if the test passed or failed.
Assistant
The test environment works with
-Djacoco.skip=true. Now let me create a temporary test to reproduce the ConnectiveStep issue. First, let me write a reproduction test:Assistant
The checkstyle is interfering. Let me skip checkstyle and just see the test results:
Assistant
Need to add the license header. Let me update the temp test file:
Assistant
I've reproduced the bug. The two multi-step ConnectiveStep tests fail with
expected:<3> but was:<1>, confirming the TINKERPOP-2911 ConnectiveStep issue. Now let me apply the fix. Let me open the file:Assistant
Let me view the exact lines to replace:
Assistant
Now let me apply the fix by replacing the
!dismissCountIsblock (lines 192-235) to add the ConnectiveStep branch and use a helper method:Assistant
Let me use the
editcommand instead. Let me open the file at the right line:Assistant
Now let me replace lines 192-235 with the new ConnectiveStep-aware logic:
Assistant
Now let me add the
transformToNotStephelper method before thedoStrategymethod:Assistant
Let me fix the missing blank line between the two methods:
Assistant
Now let me compile to verify the changes are syntactically correct:
Assistant
Compiles. Now let me run my temporary reproduction tests to verify the fix works:
Assistant
All 4 connective tests pass now. Let me also add more edge case tests to make sure the fix is robust - particularly testing the exact cases from the issue description with
out("none")patterns:Assistant
All edge case tests pass. Now let me run the existing CountStrategyCoreTest to make sure I haven't broken anything:
Assistant
All 19 existing tests pass. Let me also run broader traversal-related tests to ensure no regressions. Let me find tests that use
where/countpatterns:Assistant
There's an EdgeCoreTest at line 5469 using
__.or(__.inE().count().is(0), __.loops().is(3))- exactly a ConnectiveStep with count().is(0). Let me look at it and run it:Assistant
The
testQueryCountAsConditiontest passes. This test exercises a ConnectiveStep (or(inE().count().is(0), loops().is(3))) inside arepeat().until(). Let me run the full EdgeCoreTest and VertexCoreTest to ensure no broader regressions:Assistant
These are large test classes. Running all of them might take a while but it's worth it to verify no regressions. Let me run EdgeCoreTest first since it has the count().is(0) connective test.
Let me run them with a longer timeout.
Assistant
EdgeCoreTest: 168 tests, 0 failures, 23 skipped - all pass. Now let me run VertexCoreTest:
Assistant
Both EdgeCoreTest (168 tests) and VertexCoreTest (264 tests) pass with no failures. The fix is solid. Now let me clean up my temporary test files since the instructions say not to add tests to the repository:
Assistant
There's an unexpected change to
pom.xml. Let me check what it is - I didn't intentionally modify it:Assistant
This pom.xml change is unrelated to my fix (it appears to be an environment modification for JDK 25 build compatibility). Let me revert it to keep my submission focused on the issue:
Assistant
Let me verify the build still works with the reverted pom.xml:
Assistant
The build works fine. Let me do a final review of my changes:
Assistant
The diff is clean and focused. Let me verify there are tests exercising the plain
where(count().is(0))FilterStep path (now using clone) to confirm that change is safe too:Assistant
Let me write a quick temporary test to verify the plain
where(count().is(0))FilterStep path (now using clone) works correctly, to be thorough:Assistant
Let me see which test errored and why:
Assistant
The error in
testWhereCountIsZeroWithLabelsis a malformed test on my part -where(__.as("a")...)is invalid Gremlin usage causing a scoping error (WhereStartStep(a)looking for "a-key"), unrelated to my change. The two meaningful tests pass:testWhereCountIsZeroBecomesNot(plain FilterStep, single-step) ✓testWhereMultiStepCountIsZeroBecomesNot(plain FilterStep, multi-step) ✓
These confirm the clone change for the FilterStep path is safe. Let me verify the labeled test error is pre-existing (not a regression) by checking it against the original code with git stash:
Assistant
Confirmed - the labeled test error occurs identically on the original code, so it's a malformed test (not a regression). My change behaves identically to the original for that case. Let me clean up the temp test file:
Assistant
Now my only change is to
HugeCountStrategy.java. Let me do a final review of the complete modified file:Assistant
Let me check there's no double blank line between the methods:
Assistant
Good, single blank line. Let me do a final compile check and run the CountStrategyCoreTest to confirm everything is clean:
Assistant
Everything compiles and all tests pass. Let me do a final review of the complete diff:
Assistant
The diff is clean and focused. Let me verify the imports are all still used (since I removed the
final TraversalParent p;local variable butTraversalParentis still used in the new helper):Assistant
TraversalParentis still used. Let me run checkstyle on the core module to ensure my changes pass the project's style conventions:Assistant
Checkstyle passes. My fix is complete and verified. Let me do a final summary review of the complete file to ensure correctness:
Assistant
The fix is complete. Let me provide my final summary and checklist.
Summary
I ported the upstream TINKERPOP-2911
ConnectiveStepfix intoHugeCountStrategy, aligning HugeGraph's local fork of TinkerPop's with the upstream behavior for / traversal shapes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.