Implementation:Lance format Lance Java RestoreOp
| Knowledge Sources | |
|---|---|
| Domains | Java_SDK, Dataset_Management |
| Last Updated | 2026-02-08 19:33 GMT |
Overview
Description
The Restore class is an immutable operation that reverts a Lance dataset to a previously committed version. It implements the Operation interface and carries a single long field representing the target version number.
Lance datasets maintain automatic versioning where every write creates a new version. The Restore operation leverages this by creating a new version whose contents match a specified historical version. This is a zero-copy operation on the data layer since it only updates the manifest to point to the existing data of the target version.
Usage
Use Restore to roll back a dataset to a known good state after a problematic write, or to implement point-in-time recovery. The restored version becomes the latest version of the dataset.
Code Reference
Source Location
java/src/main/java/org/lance/operation/Restore.java
Signature
public class Restore implements Operation {
public static Builder builder();
public long version();
public String name(); // returns "Restore"
}
Import
import org.lance.operation.Restore;
I/O Contract
| Parameter | Type | Required | Description |
|---|---|---|---|
| version | long |
Yes | The dataset version number to restore to |
| Return | Type | Description |
|---|---|---|
| version() | long |
The target version number |
| name() | String |
Returns "Restore" for JNI dispatch
|
Usage Examples
// Restore the dataset to version 5
Restore restoreOp = Restore.builder()
.version(5L)
.build();
long targetVersion = restoreOp.version(); // 5
String opName = restoreOp.name(); // "Restore"
Related Pages
- Lance_format_Lance_Java_OverwriteOp -- Overwrites dataset content (creates a new version)
- Lance_format_Lance_Java_DeleteOp -- Deletes rows (creates a new version that may need rollback)