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 ScalarIndexParams

From Leeroopedia


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

Overview

Description

ScalarIndexParams is a Java class in the org.lance.index.scalar package that holds parameters for creating scalar indices in Lance. It consists of an index type string (e.g., "btree", "zonemap", "bitmap", "inverted", "labellist", "ngram") and an optional JSON string containing type-specific parameters. The class provides both static factory methods (create) and a Builder for construction.

Usage

ScalarIndexParams is typically not constructed directly by end users. Instead, specialized builder classes such as BTreeIndexParams, InvertedIndexParams, and ZoneMapIndexParams produce ScalarIndexParams instances. However, the static create() methods allow direct construction for index types without dedicated builders.

Code Reference

Source Location

java/src/main/java/org/lance/index/scalar/ScalarIndexParams.java

Signature

public class ScalarIndexParams {
    public static ScalarIndexParams create(String indexType);
    public static ScalarIndexParams create(String indexType, String jsonParams);

    public String getIndexType();
    public Optional<String> getJsonParams();

    public static class Builder {
        public Builder(String indexType);
        public Builder setJsonParams(String jsonParams);
        public ScalarIndexParams build();
    }
}

Import

import org.lance.index.scalar.ScalarIndexParams;

I/O Contract

Factory / Builder Inputs
Parameter Type Required Default Description
indexType String Yes N/A The scalar index type identifier (e.g., "btree", "zonemap", "bitmap", "inverted", "labellist", "ngram")
jsonParams String No Optional.empty() JSON string containing index-specific parameters
Accessor Outputs
Method Return Type Description
getIndexType() String The index type identifier string
getJsonParams() Optional<String> Optional JSON parameters string

Usage Examples

import org.lance.index.scalar.ScalarIndexParams;
import org.lance.index.IndexParams;

// Create a simple bitmap index with no extra parameters
ScalarIndexParams bitmap = ScalarIndexParams.create("bitmap");

// Create a label list index with no extra parameters
ScalarIndexParams labelList = ScalarIndexParams.create("labellist");

// Create a scalar index with custom JSON parameters
ScalarIndexParams custom = ScalarIndexParams.create(
    "btree",
    "{\"zone_size\": 2048}"
);

// Access the index type and params
System.out.println(bitmap.getIndexType());           // "bitmap"
System.out.println(custom.getJsonParams().get());     // {"zone_size": 2048}

// Use via IndexParams
IndexParams params = IndexParams.builder()
    .setScalarIndexParams(bitmap)
    .build();

// Or use the Builder directly
ScalarIndexParams viaBuilder = new ScalarIndexParams.Builder("ngram")
    .setJsonParams("{\"min_ngram_length\": 2}")
    .build();

Related Pages

Page Connections

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