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 CreateIndexOp

From Leeroopedia


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

Overview

Description

The CreateIndex class is an immutable operation that represents the creation and removal of indices on a Lance dataset. It implements the Operation interface and corresponds to the Rust CreateIndex struct in lance/rust/lance/src/dataset/transaction.rs. The class tracks both newly created indices and indices to be removed in a single atomic transaction, enabling index replacement workflows.

Instances are constructed through a builder pattern. Both the newIndices and removedIndices lists default to empty collections when not explicitly set.

Usage

Use CreateIndex when building or rebuilding vector or scalar indices on a Lance dataset. The operation supports adding new indices, removing old indices, or performing both simultaneously (for example, when replacing an IVF index with an HNSW index).

Code Reference

Source Location

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

Signature

public class CreateIndex implements Operation {
    public static Builder builder();
    public List<Index> getNewIndices();
    public List<Index> getRemovedIndices();
    public String name();  // returns "CreateIndex"
}

Import

import org.lance.operation.CreateIndex;

I/O Contract

Inputs
Parameter Type Required Description
newIndices List<Index> No Indices to create (defaults to empty list)
removedIndices List<Index> No Indices to remove (defaults to empty list)
Outputs
Return Type Description
getNewIndices() List<Index> The list of newly created indices
getRemovedIndices() List<Index> The list of indices to remove
name() String Returns "CreateIndex" for JNI dispatch

Usage Examples

// Create a new vector index
Index vectorIndex = buildVectorIndex("embedding_column");

CreateIndex createIndexOp = CreateIndex.builder()
    .withNewIndices(List.of(vectorIndex))
    .build();

// Replace an existing index with a new one
CreateIndex replaceIndexOp = CreateIndex.builder()
    .withNewIndices(List.of(newIndex))
    .withRemovedIndices(List.of(oldIndex))
    .build();

String opName = replaceIndexOp.name(); // "CreateIndex"

Related Pages

Page Connections

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