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 understanding the codebase, particularly the
HugeCountStrategyimplementation.Assistant
Let me run commands one at a time.
Assistant
Now let me look at the upstream TinkerPop CountStrategy to understand the TINKERPOP-2911 changes. Let me check the TinkerPop version used.
Assistant
I need to run commands one at a time.
Assistant
TinkerPop 3.5.1. Let me find the TinkerPop source jar to see the upstream CountStrategy.
Assistant
Let me look at the test structure for HugeCountStrategy and understand the current testing approach.
Assistant
I need to run one command at a time.
Assistant
Now let me understand the upstream TINKERPOP-2911 change. Let me look at the upstream CountStrategy source from a newer TinkerPop version. First, let me understand the TINKERPOP-2911 change by looking at the TinkerPop git history or the relevant source.
Assistant
Let me look at the newer TinkerPop CountStrategy source that includes TINKERPOP-2911 fix. Let me check if a newer version is available or download it.
Assistant
Let me look at the full decompiled bytecode of the doStrategy method and the main apply method to understand the difference between the 3.5.1 upstream and the HugeCountStrategy fork.
Assistant
Let me download the newer TinkerPop source to see the TINKERPOP-2911 fix.
Assistant
Now I can clearly see the TINKERPOP-2911 fix. The key difference is in the
!dismissCountIsblock: the upstream 3.7.4 has a specialConnectiveStepbranch and atransformToNotStephelper method. The HugeCountStrategy fork falls back to the oldprev-based NotStep transformation forConnectiveStepparents (since theFilterStepbranch explicitly excludesConnectiveStep).Let me open the file and make the changes.
Assistant
Now I'll replace the
!dismissCountIsblock (lines 192-235) with the upstream TINKERPOP-2911 version that handlesConnectiveStepspecially, and add thetransformToNotStephelper method.Assistant
I see there's a duplicate
} else if (size == 0) {line. Let me fix that.Assistant
Now let me add the
transformToNotStephelper method. I'll add it after theapplymethod (after line 267, beforedoStrategy).Assistant
I need to add a blank line between the
transformToNotStepmethod anddoStrategy.Assistant
Now let me verify the full file compiles. Let me check the imports - I need to make sure
TraversalHelper.removeAllStepsexists in TinkerPop 3.5.1.Assistant
removeAllStepsexists in 3.5.1. Now let me compile the module to verify the change compiles.Assistant
The generic type inference issue arises because
replaceSteprequires matching type parameters. The original code used a rawSteptype. Let me check thereplaceStepsignature and fix by using raw types in the helper or casting.Assistant
I need to use raw
Steptypes to match the original code's pattern and avoid generic inference issues. Let me update thetransformToNotStepmethod to return a rawStepand adjust theFilterStepbranch.Assistant
I need to make
filterStepraw too in the FilterStep branch to avoid the inference error.Assistant
The
forEachneedsfilterStepto beStep<?, ?>sogetLabels()returnsSet<String>. Let me fix the helper to useStep<?, ?>for filterStep while keeping notStep raw.Assistant
The compilation succeeds. Now let me write a reproduction test to verify the fix works for the connective traversal shapes mentioned in the issue. First, let me understand the test infrastructure better.
Assistant
Let me look at how tests are run and the test suite structure.
Assistant
Let me check how to run the existing tests with the rocksdb backend.
Assistant
Let me first run the existing CountStrategyCoreTest tests to make sure my changes don't break anything.
Assistant
Let me see the test results summary more clearly.
Assistant
All 19 existing tests pass. Now let me write a temporary test to reproduce the issue and verify the connective traversal shapes work correctly. Let me create a temporary test file mirroring the existing test structure.
Assistant
I need to add the license header to the test file. Let me add it.
Assistant
Let me see the full error details for the two errors.
Assistant
Let me get the actual error messages for the specific test failures (not JaCoCo).
Assistant
The "none" edge label isn't defined in HugeGraph's schema (it requires labels to be defined). Let me fix my test to define proper schema and correct assertions. Let me first verify the semantics by checking what the optimization produces, and design a proper test.
Assistant
All 4 tests pass with my fix. Now let me verify that these tests would FAIL without my fix (to confirm the fix actually addresses the issue). Let me temporarily revert the strategy change and run the tests.
Assistant
The stash also stashed the test file? No, the test file is new and untracked. Let me check.
git stashby default doesn't stash untracked files. So my new test file ConnectiveReproTest.java should still be there. But the HugeCountStrategy.java was reverted to original.Wait, but I need to recompile the core module with the original strategy, and the test module needs to be recompiled too. Let me check that the test file is still there.
Assistant
Good, the test file is untracked so it remains. Now let me run the tests against the ORIGINAL (unfixed) strategy to confirm they fail.
Assistant
The test
testWhereOrOutNoneCountIsZeroHasNonefails with the original code (expected 4, got 0), confirming the bug exists. My fix resolves it. Now let me restore my changes.Assistant
I notice
pom.xmlwas modified, but I didn't touch it. Let me check what changed there.Assistant
The
pom.xmlchange appears to be pre-existing environment setup (unrelated to my fix - it's a Lombok/compiler plugin version bump for the build environment). Let me verify my fix is restored and run the existing tests again.Assistant
Now let me run my reproduction tests once more with the fix to confirm they pass.
Assistant
All 4 connective regression cases pass. Let me also run a broader set of related tests to ensure no regressions. Let me check which other tests use count/is patterns that might be affected.
Assistant
There's an existing test using
or(__.inE().count().is(0), ...)inside arepeat().until(). This is exactly a connective pattern that could be affected. Let me look at it.Assistant
This existing test
testQueryCountAsConditionusesor(__.inE().count().is(0), ...)insideuntil(). Let me run it to confirm my change doesn't break it.Assistant
Now let me run the VertexCoreTest count-related tests and a broader check to be safe.
Assistant
Let me run the full EdgeCoreTest to ensure no regressions in edge-related count patterns.
Assistant
All 168 EdgeCoreTest tests pass. Now let me clean up by removing my temporary test file, since the instructions say not to add new tests to the repository.
Assistant
Let me do a final review of my changes to
HugeCountStrategy.java.Assistant
The diff for
HugeCountStrategy.javais clean and correct. Now let me reconsider thepom.xmlchange - it's unrelated to my fix and appears to be pre-existing environment setup. Let me check whether it was present before my session and whether the build depends on it.Assistant
Let me verify the compile result more carefully with the original pom.xml.
Assistant
The build succeeds with the original
pom.xml(Lombok 1.18.30), so the pom.xml change is unnecessary environment setup unrelated to my fix. I've stashed it out. Let me verify the current state and run the tests once more with the clean pom.xml to confirm everything works.Assistant
Only
HugeCountStrategy.javais modified now. Let me drop the stash and re-run the tests with the clean original pom.xml to confirm everything still works.Assistant
All 19 tests pass with the clean original pom.xml. Let me do a final verification of the complete state.
Assistant
The submission is clean - only
HugeCountStrategy.javais modified. Let me do a final review of the complete modified file to ensure correctness.Assistant
The implementation looks correct and complete. Let me run one final compilation check to be absolutely sure everything compiles cleanly.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.