Skip to content

feat(java): add Dataset.takeRows() for physical row ID access#6772

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
alex766:feat/java-take-rows
May 14, 2026
Merged

feat(java): add Dataset.takeRows() for physical row ID access#6772
Xuanwo merged 2 commits into
lance-format:mainfrom
alex766:feat/java-take-rows

Conversation

@alex766

@alex766 alex766 commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Dataset.takeRows(List<Long> rowIds, List<String> columns) to the Java SDK, mirroring Rust's existing Dataset::take_rows() by adding a JNI binding

take() accepts logical row indices (positions). takeRows() accepts physical row IDs from the _rowid system column — these are stable across compaction and deletion, which makes them suitable for applications that store row IDs externally (e.g., in a secondary index) and later need to fetch the corresponding row data.

Changes

  • java/lance-jni/src/blocking_dataset.rs: JNI shim nativeTakeRows + inner_take_rows — mirrors inner_take but calls
    dataset.take_rows() instead of dataset.take()
  • java/src/main/java/org/lance/Dataset.java: public takeRows() method + native declaration
  • java/src/test/java/org/lance/DatasetTest.java: testTakeRows covering correctness, input-order preservation, and edge cases (empty/null rejection)

Add a JNI binding for Rust's Dataset::take_rows(), which fetches rows by
their stable physical row IDs (from the _rowid system column) rather than
logical indices.

Mirrors the existing take() API but uses row IDs that persist across
compaction and deletion. The Rust side already exposes take_rows() -- this
commit wires it through JNI to Java.

Changes:
- blocking_dataset.rs: nativeTakeRows JNI function + inner_take_rows
- Dataset.java: takeRows() public method + nativeTakeRows native declaration
- DatasetTest.java: testTakeRows with ordering verification and edge cases

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added enhancement New feature or request A-java Java bindings + JNI labels May 13, 2026

@hamersaw hamersaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Looks great.

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Xuanwo
Xuanwo merged commit d005f66 into lance-format:main May 14, 2026
7 checks passed
geruh pushed a commit to geruh/lance that referenced this pull request May 16, 2026
…format#6772)

## Summary
Adds `Dataset.takeRows(List<Long> rowIds, List<String> columns)` to the
Java SDK, mirroring Rust's existing `Dataset::take_rows()` by adding a
JNI binding

`take()` accepts logical row indices (positions). `takeRows()` accepts
physical row IDs from the `_rowid` system column — these are stable
across compaction and deletion, which makes them suitable for
applications that store row IDs externally (e.g., in a secondary index)
and later need to fetch the corresponding row data.

## Changes
- `java/lance-jni/src/blocking_dataset.rs`: JNI shim `nativeTakeRows` +
`inner_take_rows` — mirrors `inner_take` but calls
  `dataset.take_rows()` instead of `dataset.take()`
- `java/src/main/java/org/lance/Dataset.java`: public `takeRows()`
method + native declaration
- `java/src/test/java/org/lance/DatasetTest.java`: `testTakeRows`
covering correctness, input-order preservation, and edge cases
(empty/null rejection)

---------

Co-authored-by: Alexandra Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-java Java bindings + JNI enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants