Implementation:Lance format Lance Java BTreeIndexParams
| Knowledge Sources | |
|---|---|
| Domains | Java_SDK, Indexing |
| Last Updated | 2026-02-08 19:33 GMT |
Overview
Description
BTreeIndexParams is a final Java class in the org.lance.index.scalar package that provides a builder-style configuration for B-Tree scalar index parameters. It is a convenience wrapper that constructs a ScalarIndexParams instance with the index type set to "btree". The builder supports two optional parameters: zoneSize (number of rows per zone) and rangeId (ordinal ID for distributed BTree index builds). Parameters are serialized to JSON using JsonUtils and passed to ScalarIndexParams.create().
Usage
Use BTreeIndexParams.builder() to configure B-Tree index options. The build() method returns a ScalarIndexParams object (not a BTreeIndexParams instance), which can then be set on an IndexParams builder.
Code Reference
Source Location
java/src/main/java/org/lance/index/scalar/BTreeIndexParams.java
Signature
public final class BTreeIndexParams {
public static Builder builder();
public static final class Builder {
public Builder zoneSize(long zoneSize);
public Builder rangeId(int rangeId);
public ScalarIndexParams build();
}
}
Import
import org.lance.index.scalar.BTreeIndexParams;
I/O Contract
| Parameter | Type | Required | Default | Validation | Description |
|---|---|---|---|---|---|
zoneSize |
long |
No | Not set | Must be positive | Number of rows per zone in the B-Tree |
rangeId |
int |
No | Not set | Must be non-negative | Ordinal ID of a data partition for building a large, distributed BTree index |
| Return Type | Description |
|---|---|
ScalarIndexParams |
A scalar index params object with type "btree" and optional JSON configuration
|
| Key | Type | Description |
|---|---|---|
zone_size |
long |
Number of rows per zone |
range_id |
int |
Range identifier for distributed builds |
Usage Examples
import org.lance.index.scalar.BTreeIndexParams;
import org.lance.index.scalar.ScalarIndexParams;
import org.lance.index.IndexParams;
// Create a default BTree index (no custom zone size or range)
ScalarIndexParams defaultBTree = BTreeIndexParams.builder().build();
// Create a BTree index with a custom zone size
ScalarIndexParams customBTree = BTreeIndexParams.builder()
.zoneSize(4096)
.build();
// Create a distributed BTree with range partitioning
ScalarIndexParams distributedBTree = BTreeIndexParams.builder()
.zoneSize(2048)
.rangeId(3)
.build();
// Wrap in IndexParams for use with IndexOptions
IndexParams params = IndexParams.builder()
.setScalarIndexParams(customBTree)
.build();
Related Pages
- ScalarIndexParams - The output type produced by
BTreeIndexParams.Builder.build() - IndexParams - Top-level container that holds scalar index params
- ZoneMapIndexParams - Another scalar index builder for zone map indices
- IndexType - Contains the
BTREEenum constant