Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Lance format Lance Java RewriteOp

From Leeroopedia
Revision as of 15:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Lance_format_Lance_Java_RewriteOp.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Java_SDK, Dataset_Management
Last Updated 2026-02-08 19:33 GMT

Overview

Description

The Rewrite class is an immutable operation for reorganizing data within a Lance dataset without changing its logical content. It implements the Operation interface and is the primary mechanism for data compaction and reordering. Because the operation modifies the physical addresses of existing rows, any vector or scalar indices that cover the rewritten fragments must be remapped.

The operation contains three components: a list of RewriteGroup objects (each mapping old fragments to new fragments), a list of RewrittenIndex objects (tracking index remapping), and an optional Index for fragment reuse optimization. All lists default to empty when not set.

Usage

Use Rewrite for compaction operations that consolidate small fragments into larger ones, remove deleted row tombstones, or physically reorder data for improved scan performance. After a rewrite, affected indices are remapped using the rewrittenIndices list.

Code Reference

Source Location

java/src/main/java/org/lance/operation/Rewrite.java

Signature

public class Rewrite implements Operation {
    public static Builder builder();
    public List<RewriteGroup> groups();
    public List<RewrittenIndex> rewrittenIndices();
    public Optional<Index> fragReuseIndex();
    public String name();  // returns "Rewrite"
}

Import

import org.lance.operation.Rewrite;

I/O Contract

Inputs
Parameter Type Required Description
groups List<RewriteGroup> No Groups mapping old fragments to new fragments (defaults to empty)
rewrittenIndices List<RewrittenIndex> No Index remapping entries for affected indices (defaults to empty)
fragReuseIndex Index No Optional index for fragment reuse optimization
Outputs
Return Type Description
groups() List<RewriteGroup> The rewrite groups mapping old to new fragments
rewrittenIndices() List<RewrittenIndex> Index remapping entries
fragReuseIndex() Optional<Index> The fragment reuse index, if present
name() String Returns "Rewrite" for JNI dispatch

Usage Examples

// Compact fragments: merge old fragments into new, larger fragments
RewriteGroup group = new RewriteGroup(oldFragments, newFragments);

Rewrite rewriteOp = Rewrite.builder()
    .groups(List.of(group))
    .rewrittenIndices(List.of(remappedIndex))
    .build();

String opName = rewriteOp.name(); // "Rewrite"
List<RewriteGroup> groups = rewriteOp.groups();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment