Skip to content

feat(java): expose MemWAL shard delete#7688

Merged
hamersaw merged 1 commit into
lance-format:mainfrom
hamersaw:feature/java-wal-delete
Jul 9, 2026
Merged

feat(java): expose MemWAL shard delete#7688
hamersaw merged 1 commit into
lance-format:mainfrom
hamersaw:feature/java-wal-delete

Conversation

@hamersaw

@hamersaw hamersaw commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Mirrors the Python ShardWriter.delete binding on the Java side, bringing the Java MemWAL bindings to parity with Python. The Rust core ShardWriter::delete and the Python binding already exist; this wires up the Java surface.

  • java/lance-jni/src/mem_wal.rsnativeDelete JNI entry point (inner_delete) that streams Arrow key batches into ShardWriter::delete, mirroring nativePut/inner_put.
  • ShardWriter.java — public delete(ArrowReader) wrapper mirroring put, with Javadoc copied from the Rust core (tombstone semantics, nullable-column and primary-key constraints).
  • MemWalTest.java — integration test testShardWriterDeleteMasksBaseRow asserting a tombstone masks the deleted base row, mirroring the Python test_shard_writer_delete_binding_masks_base_row.

All validation and tombstone construction stay centralized in the Rust core — the binding is a thin wrapper, per the cross-language binding guidelines.

Testing

  • cargo clippy --tests --manifest-path ./lance-jni/Cargo.toml — clean
  • ./mvnw spotless:check + cargo fmt — clean
  • ./mvnw test -Dtest=MemWalTest#testShardWriterDeleteMasksBaseRowTests run: 1, Failures: 0

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for deleting records through the shard writer API.
    • Deletions now work using primary-key-only input and are reflected as hidden tombstone rows.
  • Bug Fixes
    • Deleted rows are now masked from query results while preserving other existing records and newly added data.
    • Added validation and safer handling for empty delete inputs and invalid usage.
  • Tests
    • Added an integration test covering delete behavior and tombstone masking.

Mirror the Python ShardWriter.delete binding on the Java side. Adds a
nativeDelete JNI entry point that streams Arrow key batches into the Rust
core's ShardWriter::delete, plus a public delete(ArrowReader) wrapper and
an integration test asserting a tombstone masks the deleted base row.

All validation and tombstone construction stays in the Rust core; the
binding is a thin wrapper mirroring put.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added A-java Java bindings + JNI enhancement New feature or request labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bc61d37-83b8-4950-9e65-7f03fae31b84

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
java/src/test/java/org/lance/memwal/MemWalTest.java (1)

100-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider covering delete error paths.

The new Javadoc for ShardWriter.delete documents several error conditions (missing PK column, non-nullable non-PK column, non-memtable mode), but testShardWriterDeleteMasksBaseRow only exercises the success path. Adding a test asserting these error cases would strengthen coverage for the new native call surface.

Also applies to: 401-445

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@java/src/test/java/org/lance/memwal/MemWalTest.java` around lines 100 - 114,
The delete-path tests only cover the happy case, so add coverage in MemWalTest
for the error conditions documented by ShardWriter.delete: missing primary-key
column, presence of a non-nullable non-PK column, and calling delete when not in
memtable mode. Reuse the existing test setup around
testShardWriterDeleteMasksBaseRow and keysRoot, and add focused assertions that
the delete invocation fails with the expected errors for each case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@java/src/test/java/org/lance/memwal/MemWalTest.java`:
- Around line 100-114: The delete-path tests only cover the happy case, so add
coverage in MemWalTest for the error conditions documented by
ShardWriter.delete: missing primary-key column, presence of a non-nullable
non-PK column, and calling delete when not in memtable mode. Reuse the existing
test setup around testShardWriterDeleteMasksBaseRow and keysRoot, and add
focused assertions that the delete invocation fails with the expected errors for
each case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 705e75e6-4247-40de-a20e-97c118d6479f

📥 Commits

Reviewing files that changed from the base of the PR and between c5316c6 and 8e8009e.

📒 Files selected for processing (3)
  • java/lance-jni/src/mem_wal.rs
  • java/src/main/java/org/lance/memwal/ShardWriter.java
  • java/src/test/java/org/lance/memwal/MemWalTest.java

@hamersaw hamersaw merged commit ef256e2 into lance-format:main Jul 9, 2026
14 checks passed
@hamersaw hamersaw deleted the feature/java-wal-delete branch July 9, 2026 15:36
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.

2 participants