Implementation:Lance format Lance Java DeleteOp
| Knowledge Sources | |
|---|---|
| Domains | Java_SDK, Dataset_Management |
| Last Updated | 2026-02-08 19:33 GMT |
Overview
Description
The Delete class is an immutable operation that represents the deletion of rows from a Lance dataset. It implements the Operation interface and supports two complementary deletion mechanisms: updating fragment metadata to mark rows as deleted (soft delete via deletion bitmaps), and removing entire fragments when all their rows are deleted.
The operation records a SQL-like predicate string describing the deletion condition, a list of FragmentMetadata objects for fragments that were partially affected (updated with deletion vectors), and a list of fragment IDs for fragments that were entirely removed. All three fields default to empty values when not set.
Usage
Use Delete to remove rows matching a predicate from a Lance dataset. This is the standard row-level delete path. Fragments where only some rows match receive updated deletion vectors, while fragments where all rows match are recorded for full removal.
Code Reference
Source Location
java/src/main/java/org/lance/operation/Delete.java
Signature
public class Delete implements Operation {
public static Builder builder();
public List<FragmentMetadata> updatedFragments();
public List<Long> deletedFragmentIds();
public String predicate();
public String name(); // returns "Delete"
}
Import
import org.lance.operation.Delete;
I/O Contract
| Parameter | Type | Required | Description |
|---|---|---|---|
| updatedFragments | List<FragmentMetadata> |
No | Fragments with updated deletion vectors (defaults to empty) |
| deletedFragmentIds | List<Long> |
No | IDs of fully deleted fragments (defaults to empty) |
| predicate | String |
No | SQL filter expression describing which rows to delete (defaults to empty string) |
| Return | Type | Description |
|---|---|---|
| updatedFragments() | List<FragmentMetadata> |
Fragments that were partially affected with updated deletion bitmaps |
| deletedFragmentIds() | List<Long> |
Fragment IDs for fragments entirely removed |
| predicate() | String |
The deletion predicate expression |
| name() | String |
Returns "Delete" for JNI dispatch
|
Usage Examples
// Delete rows matching a predicate
Delete deleteOp = Delete.builder()
.predicate("age < 18")
.updatedFragments(fragmentsWithDeletionVectors)
.deletedFragmentIds(List.of(5L, 12L))
.build();
String opName = deleteOp.name(); // "Delete"
String pred = deleteOp.predicate(); // "age < 18"
Related Pages
- Lance_format_Lance_Java_UpdateOp -- Updates specific rows or columns in the dataset
- Lance_format_Lance_Java_OverwriteOp -- Replaces the entire dataset content
- Lance_format_Lance_Java_AppendOp -- Adds new rows to the dataset