TINKERPOP-3244 Add NextN(n) to Traversal in gremlin-go (3.7-dev)#3430
Open
L0Lmaker wants to merge 1 commit into
Open
TINKERPOP-3244 Add NextN(n) to Traversal in gremlin-go (3.7-dev)#3430L0Lmaker wants to merge 1 commit into
L0Lmaker wants to merge 1 commit into
Conversation
Backport of apache#3416 to 3.7-dev. Adds a batched-iteration terminator that returns up to n results, mirroring next(n) in the Java, Python, and .NET GLVs. Go does not support method overloading, so this lands as a sibling method to the existing Next() rather than a second Next(int) signature. Behavior matches the Java reference: returns up to n results, returns what is available if fewer exist, returns an empty slice for non-positive n, and surfaces ResultSet errors to the caller. The 3.7-dev iteration model uses ResultSet.One() directly (no nextValue() helper); bulks are unrolled in channelResultSet.addResult, so NextN can simply loop over One() and inherit unrolling. gremlin-core's GoTranslateVisitor and gremlin-javascript do not exist on 3.7-dev, so no translator changes are included. Assisted-by: Claude Code:claude-opus-4-7
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.7-dev #3430 +/- ##
=============================================
- Coverage 76.14% 75.49% -0.65%
- Complexity 13152 13161 +9
=============================================
Files 1084 1092 +8
Lines 65160 67208 +2048
Branches 7285 7391 +106
=============================================
+ Hits 49616 50742 +1126
- Misses 12839 13837 +998
+ Partials 2705 2629 -76 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
VOTE +1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of #3416 to
3.7-dev. AddsTraversal.NextN(n int) ([]*Result, error)to gremlin-go for batched result iteration, providing API parity with
next(n)in the Java, Python, and .NET GLVs.
nresults, returns what isavailable if fewer exist, returns an empty slice for
n <= 0, and surfacesResultSeterrors to the caller.NextNrather thanNext(n int)because Go does not supportmethod overloading. The Go variants reference doc is updated to call this out.
Scope vs. #3416: the master PR also updated the Go translators in
gremlin-core(
GoTranslateVisitor.java) andgremlin-js(GoTranslateVisitor.ts) to emitNextN(n)for the batched terminal form. Those translator files do not exist on3.7-dev, so the backport correctly omits those changes.JIRA
TINKERPOP-3244
3.8 backport
A separate PR for
3.8-devwill follow after the3.7-dev → 3.8-devflow-upmerge brings the
gremlin-goportion forward. The follow-up PR will be scopedto the
3.8-only delta: theGoTranslateVisitor.javaupdate and thecorresponding 3.8.2 CHANGELOG entry. Keeping the two PRs separated this way
avoids overlap with the flow-up merge.
Test plan
go build ./...cleango vet ./driver/cleangofmt -l driver/traversal.go driver/traversal_test.gocleanTestTraversalNextN— all 9 subtests pass:n < available,n == available,n > available,n = 0,n < 0, exhausted traversal, bulked traverserunrolling across batch boundary, repeated drain calls, error propagation
TestTraversal/Test_clone_traversal,TestTraversal/Test_Iterate_with_empty_removeConnection) still passbuild-test.ymlCI matrix on the fork (smoke, java jdk8/11/17,gremlin-server-default/-unified, gremlin-console, gremlin-driver, hadoop,
spark, neo4j, javascript, python, dotnet, go) all green at
4722890./run.sh— not run locally; relying on fork CI'sgojob which executes the gremlin-go test containerNotes
This change was AI-assisted; the commit includes the
Assisted-by:trailer perAGENTS.md.