[
https://issues.apache.org/jira/browse/TINKERPOP-3244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081919#comment-18081919
]
ASF GitHub Bot commented on TINKERPOP-3244:
-------------------------------------------
L0Lmaker opened a new pull request, #3430:
URL: https://github.com/apache/tinkerpop/pull/3430
## Summary
Backport of #3416 to `3.7-dev`. Adds `Traversal.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.
- Behavior matches the Java reference: returns up to `n` results, returns
what is
available if fewer exist, returns an empty slice for `n <= 0`, and surfaces
`ResultSet` errors to the caller.
- Method is named `NextN` rather than `Next(n int)` because Go does not
support
method 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`) and `gremlin-js` (`GoTranslateVisitor.ts`) to
emit
`NextN(n)` for the batched terminal form. Those translator files do not
exist on
`3.7-dev`, so the backport correctly omits those changes.
## JIRA
[TINKERPOP-3244](https://issues.apache.org/jira/browse/TINKERPOP-3244)
## 3.8 backport
A separate PR for `3.8-dev` will follow after the `3.7-dev → 3.8-dev` flow-up
merge brings the `gremlin-go` portion forward. The follow-up PR will be
scoped
to the `3.8`-only delta: the `GoTranslateVisitor.java` update and the
corresponding 3.8.2 CHANGELOG entry. Keeping the two PRs separated this way
avoids overlap with the flow-up merge.
## Test plan
- [x] `go build ./...` clean
- [x] `go vet ./driver/` clean
- [x] `gofmt -l driver/traversal.go driver/traversal_test.go` clean
- [x] `TestTraversalNextN` — all 9 subtests pass: `n < available`, `n ==
available`,
`n > available`, `n = 0`, `n < 0`, exhausted traversal, bulked
traverser
unrolling across batch boundary, repeated drain calls, error
propagation
- [x] Existing no-server tests (`TestTraversal/Test_clone_traversal`,
`TestTraversal/Test_Iterate_with_empty_removeConnection`) still pass
- [x] Full `build-test.yml` CI 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`
- [ ] Full integration suite via `./run.sh` — not run locally; relying on
fork CI's
`go` job which executes the gremlin-go test container
## Notes
This change was AI-assisted; the commit includes the `Assisted-by:` trailer
per `AGENTS.md`.
> Add next(n) batch iteration to gremlin-go for GLV parity
> --------------------------------------------------------
>
> Key: TINKERPOP-3244
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3244
> Project: TinkerPop
> Issue Type: Improvement
> Components: driver
> Affects Versions: 3.7.5, 3.8.1
> Reporter: Taylor Riggan
> Priority: Minor
>
> The Java, Python, and .NET GLVs all support `next\(n\)` on Traversal to
> retrieve multiple results at once, but gremlin-go only supports single-item
> `Next()` returning `(*Result, error)`. This creates an API inconsistency
> across GLVs that makes it harder to write portable examples and documentation.
> Currently, users must manually collect results from `GetResultSet()` +
> `One()` in a loop to achieve the same behavior. A `Next(n int) ([]*Result,
> error)` method on `Traversal` would bring gremlin-go in line with the other
> GLVs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)