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 OptimizeOptions

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


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

Overview

Description

OptimizeOptions is a Java class in the org.lance.index package that defines options for optimizing indices on a Lance dataset. It mirrors the behavior of lance_index::optimize::OptimizeOptions in Rust. The class supports configuring the number of indices to merge per index name, restricting optimization to specific index names, and choosing between incremental merge and full retraining. All fields except retrain are optional, with defaults delegated to the Rust implementation.

Usage

OptimizeOptions is constructed via OptimizeOptions.builder() and passed to dataset optimize-indices APIs. When no index names are provided, all user indices are considered (system indices are always excluded).

Code Reference

Source Location

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

Signature

public class OptimizeOptions {
    public static Builder builder();

    public Optional<Integer> getNumIndicesToMerge();
    public Optional<List<String>> getIndexNames();
    public boolean isRetrain();

    public static class Builder {
        public Builder numIndicesToMerge(int numIndicesToMerge);
        public Builder indexNames(List<String> indexNames);
        public Builder retrain(boolean retrain);
        public OptimizeOptions build();
    }
}

Import

import org.lance.index.OptimizeOptions;

I/O Contract

Builder Inputs
Parameter Type Required Default Description
numIndicesToMerge int No Optional.empty() (Rust default) Number of indices to merge per index name
indexNames List<String> No Optional.empty() (all user indices) Names of indices to optimize; if empty, all user indices are considered
retrain boolean No false Whether to retrain the index instead of incremental merge
Accessor Outputs
Method Return Type Description
getNumIndicesToMerge() Optional<Integer> Number of indices to merge, if set
getIndexNames() Optional<List<String>> Index names to optimize, if restricted
isRetrain() boolean Whether retraining is enabled

Usage Examples

import org.lance.index.OptimizeOptions;
import java.util.Arrays;

// Optimize all indices with default merge settings
OptimizeOptions defaultOptions = OptimizeOptions.builder().build();

// Optimize specific indices with incremental merge
OptimizeOptions mergeOptions = OptimizeOptions.builder()
    .indexNames(Arrays.asList("embedding_idx", "category_idx"))
    .numIndicesToMerge(5)
    .build();

// Retrain a specific index from scratch
OptimizeOptions retrainOptions = OptimizeOptions.builder()
    .indexNames(Arrays.asList("embedding_idx"))
    .retrain(true)
    .build();

Related Pages

  • Index - Index metadata that may be optimized
  • IndexOptions - Options for creating indices (complementary to optimization)
  • IndexDescription - Describes indices that can be targets for optimization

Page Connections

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