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 Index

From Leeroopedia


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

Overview

Description

Index is a Java class in the org.lance.index package that represents metadata for an index in a Lance dataset. It corresponds to the Rust Index struct defined in lance/rust/lance-table/src/format/index.rs. The class is immutable and uses a Builder pattern for construction. Each Index instance holds a UUID identifier, the list of field IDs covered by the index, a human-readable name, the dataset version it covers, optional fragment information, serialized index details, the index version, creation timestamp, an optional base ID for delta indices, and the IndexType.

Usage

Index objects are typically returned by the Lance Java SDK when querying the metadata of existing indices on a dataset. They are constructed via Index.builder() and provide accessor methods for all index metadata fields. The class implements equals(), hashCode(), and toString() for proper use in collections and debugging.

Code Reference

Source Location

java/src/main/java/org/lance/index/Index.java

Signature

public class Index {
    // Private constructor; use Builder
    public static Builder builder();

    public UUID uuid();
    public List<Integer> fields();
    public String name();
    public long datasetVersion();
    public Optional<List<Integer>> fragments();
    public Optional<byte[]> indexDetails();
    public Optional<Integer> baseId();
    public int indexVersion();
    public Optional<Instant> createdAt();
    public IndexType indexType();

    public static class Builder { ... }
}

Import

import org.lance.index.Index;

I/O Contract

Builder Inputs
Parameter Type Required Description
uuid UUID Yes Unique identifier for the index
fields List<Integer> Yes Field IDs included in the index
name String Yes Human-readable index name
datasetVersion long Yes Latest dataset version this index covers
fragments List<Integer> No Optional list of fragment IDs
indexDetails byte[] No Optional serialized index details
indexVersion int Yes Version of the index
createdAt Instant No Optional creation timestamp
baseId Integer No Optional base ID for delta indices
indexType IndexType Yes The type of the index (e.g., BTREE, VECTOR)
Accessor Outputs
Method Return Type Description
uuid() UUID The unique index identifier
fields() List<Integer> The field IDs in the index
name() String Human-readable name
datasetVersion() long Dataset version covered
fragments() Optional<List<Integer>> Optional fragment IDs
indexDetails() Optional<byte[]> Optional serialized details
indexVersion() int Index version number
createdAt() Optional<Instant> Optional creation time
baseId() Optional<Integer> Optional delta base ID
indexType() IndexType The index type

Usage Examples

import org.lance.index.Index;
import org.lance.index.IndexType;
import java.util.Arrays;
import java.util.UUID;

// Build an Index metadata object
Index index = Index.builder()
    .uuid(UUID.randomUUID())
    .fields(Arrays.asList(0, 1))
    .name("my_vector_idx")
    .datasetVersion(5)
    .indexVersion(1)
    .indexType(IndexType.IVF_PQ)
    .build();

// Access metadata
System.out.println("Index name: " + index.name());
System.out.println("Dataset version: " + index.datasetVersion());
System.out.println("Type: " + index.indexType());
index.createdAt().ifPresent(ts -> System.out.println("Created: " + ts));

Related Pages

  • IndexType - Enum used to classify the index type
  • IndexDescription - High-level index description that contains a list of Index segments
  • IndexOptions - Options for building indices on a dataset

Page Connections

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