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
I’ll first locate
HugeCountStrategy, its tests, and the project’s TinkerPop version. Then I’ll compare the local traversal-rewrite logic with any newerCountStrategysource available in repository dependencies or local caches, reproduce the connective behavior through focused existing tests or a temporary harness, patch only production code, and run the affected test suite. - Assistant
The relevant implementation and a dedicated core test class are present, and this branch uses TinkerPop 3.5.1 (predating the upstream follow-up). I’ll inspect both files and repository history around the fork to understand exactly which older algorithm was copied and where connective recursion currently differs.
- Assistant
The fork contains a special
!(p instanceof ConnectiveStep)branch when replacing a parent filter withNotStep; that is the likely pre-TINKERPOP-2911 behavior. To avoid guessing the upstream patch, I’ll inspect locally cached Maven source JARs and installed binary distributions for later TinkerPop versions, plus the original commit diff and complete method. This stays entirely within repository/local artifacts. - Assistant
Only 3.5.1 is cached, so I’ll use repository Git objects and the bundled class as the baseline. I’ll also inspect how strategies are applied recursively and construct the four suggested traversals on an in-memory
TinkerGraphwith the local strategy. Printing traversal structures before/after strategy application and results should expose whether the connective child traversal is being replaced incorrectly. - Assistant
The baseline bytecode confirms the local fork exactly inherited 3.5.1’s connective exclusion. The key distinction is that replacing an ordinary filter parent can safely negate the whole filter, while replacing a
ConnectiveStepfrom one child would corrupt sibling branches. I’ll now inspect the strategy recursion order andConnectiveStepAPIs, then run the actual suggested shapes against HugeGraph’s test backend (without modifying tests) by temporarily invoking them through the project’s existing test infrastructure or a standalone Java file under/tmp. - Assistant
A standalone TinkerGraph reproduction is sufficient because this bug concerns traversal rewriting rather than HugeGraph storage. I’ll compile
hugegraph-core, generate its dependency classpath, and execute a/tmpJava harness that compares each suggested traversal with and withoutHugeCountStrategy, including post-strategy traversal strings. This avoids any test-file changes. - Assistant
Compilation succeeded; only the separate classpath-generation invocation failed because Maven lost the reactor’s
${revision}interpolation. I’ll bypass that tooling issue using the already-cached JARs and compiled classes. The harness will explicitly remove the built-inCountStrategy, addHugeCountStrategy, and compare against an unoptimized traversal source. - Assistant
The harness itself is ready, but a classpath containing every cached JAR exceeded the OS argument limit. I’ll use only HugeGraph core, TinkerPop’s cached artifacts, and their direct utility dependencies, adding any missing runtime class indicated by Java rather than broadening indiscriminately.
- Assistant
The fixed paths assumed
$HOME=/root, but this shell’s Java cache location and$HOMEdiffer. I’ll resolve the JAR paths withfindrather than shell-home expansion and retry. - Assistant
Compilation now reaches dependencies but discovers an unrelated annotation processor from
hugegraph-corewhose own Javapoet dependency is absent. Since the temporary harness needs no annotation processing, I’ll disable processors with-proc:noneand rerun. - Assistant
The harness compiles; runtime now identifies one missing direct Commons dependency. I’ll add Commons Logging (and retain the narrow dependency set) and execute again.
- Assistant
Commons Configuration also requires Commons Text in this cached version. I’ll add it and rerun the completed harness.
- Assistant
Traversal strategy application additionally needs Javatuples. I’ll add that final reported dependency and capture the baseline results and rewritten shapes.
- Assistant
The reproduction confirms the reported drift: the first, second, and fourth shapes happen to retain results, but the third does not (
expectedall three vertices, optimized only one). The rewritten first connective branch isout("none").not(out()); this incorrectly requires the prefix to produce a traverser. Forcount().is(0), the correct rewrite isnot(out("none").out()), wrapping the entire connective child prefix.I’ll patch the connective-specific path so it moves every remaining child step into the new
NotStep, while preserving the existing ordinary-filter behavior and HugeGraph’s negative-bound guards. I’ll use a small helper to make ownership/removal explicit and update loop bookkeeping after collapsing the child to one step. - Assistant
Python is unavailable, so that edit did not occur. Maven’s flatten plugin did modify the root
pom.xmlduring the earlier install; that is generated build noise and must not be submitted, so I’ll restore it immediately. Then I’ll apply the focused source replacement using the providedreplaceeditor command. - Assistant
I’ll insert a dedicated
ConnectiveStepcase ahead of the ordinaryFilterStepcase. It collapses the now count-free child traversal into oneNotStep; all existing handling remains unchanged for repeat, where, side-effect, and root traversals. - Assistant
The patch is syntactically clean and isolated to production code. I’ll compile the module without
install(avoiding flatten-plugin changes), then rerun the exact four-case baseline harness. The key expected structural change isNotStep([out("none"), out()])and equality for all cases. - Assistant
The reproduction now passes all four suggested shapes, and the previously failing rewrite is structurally correct. I’ll run the dedicated
CountStrategyCoreTestthrough the reactor, allowing upstream modules with no matching test class to proceed. This verifies both the original negative-bound safeguards and storage-backed HugeGraph behavior. - Assistant
The full-root reactor test is blocked before reaching HugeGraph tests by unrelated existing Lombok/generated-method compilation failures in
hg-store-client. Since the affected code belongs to the server reactor and its dependencies were already built, I’ll rerun fromhugegraph-server/pom.xml, which excludes the broken store reactor. If backend configuration still prevents execution, the focused harness and successful core package remain valid verification. - Assistant
The server-only test invocation is also blocked by the repository’s unresolved flattened
${revision}parent artifact, not by this change. Before finalizing, I’ll exercise two edge cases in the temporary harness: an empty connective prefix (count().is(0)) and a longer filter prefix. This checks that moving zero/all child steps intonot()preserves identity semantics and step order. Then I’ll review the final diff and ensure only the intended source file is modified. - Assistant
The edge harness had an invalid Gremlin DSL call (
hasLabel()requires an argument), so it did not execute and does not indicate a production failure. I’ll correct the temporary-only traversal to usefilter(__.identity()), which supplies a genuine longer filter prefix, and rerun both edge cases. - Assistant
The empty-prefix edge case exposed an important distinction: an empty
__.start()child is not identity when used byNotStep, whereas the original strategy deliberately used__.identity()for this case. I’ll preserve that behavior in the connective branch: use identity when no prefix remains, otherwise move the full prefix in order. This retains the upstream connective fix without regressingcount().is(0)directly insideand/or. - Assistant
The corrected implementation compiles successfully. I’ll rerun the expanded harness after this final build; all six cases must match the unoptimized traversal. Then I’ll perform a last status/diff review before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.