Skip to content

TINKERPOP-3244 Add NextN(n) to Traversal in gremlin-go (3.7-dev)#3430

Open
L0Lmaker wants to merge 1 commit into
apache:3.7-devfrom
L0Lmaker:improvement/TINKERPOP-3244-go-next-n-3.7
Open

TINKERPOP-3244 Add NextN(n) to Traversal in gremlin-go (3.7-dev)#3430
L0Lmaker wants to merge 1 commit into
apache:3.7-devfrom
L0Lmaker:improvement/TINKERPOP-3244-go-next-n-3.7

Conversation

@L0Lmaker
Copy link
Copy Markdown
Contributor

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

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

  • go build ./... clean
  • go vet ./driver/ clean
  • gofmt -l driver/traversal.go driver/traversal_test.go clean
  • 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
  • Existing no-server tests (TestTraversal/Test_clone_traversal,
    TestTraversal/Test_Iterate_with_empty_removeConnection) still pass
  • 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.

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
@L0Lmaker L0Lmaker requested review from Cole-Greer and xiazcy May 19, 2026 06:10
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.49%. Comparing base (9b46b67) to head (4722890).
⚠️ Report is 463 commits behind head on 3.7-dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Cole-Greer
Copy link
Copy Markdown
Contributor

VOTE +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants