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 LanceSchema

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


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

Overview

Description

The LanceSchema class represents a Lance dataset schema containing a list of LanceField objects and schema-level metadata. It extends the standard Arrow schema concept with Lance-specific field information such as field IDs, logical types, and primary key annotations.

The class provides an asArrowSchema() method that converts the entire Lance schema to a standard Apache Arrow Schema by delegating to each LanceField.asArrowField(). The metadata map is returned as an unmodifiable view to prevent mutation. Construction is package-private, with instances typically created by the JNI layer when reading schema information from native Lance datasets.

A private Builder class is available for internal construction with withFields() and withMetadata() methods.

Usage

Obtain a LanceSchema from a Dataset to access Lance-specific field metadata such as field IDs, logical types, and primary key annotations. Convert to a standard Arrow Schema via asArrowSchema() when working with Arrow-native tools.

Code Reference

Source Location

java/src/main/java/org/lance/schema/LanceSchema.java

Signature

public class LanceSchema {
    public List<LanceField> fields();
    public Map<String, String> metadata();
    public Schema asArrowSchema();
}

Import

import org.lance.schema.LanceSchema;

I/O Contract

Schema Properties
Property Type Description
fields List<LanceField> Ordered list of top-level Lance fields
metadata Map<String, String> Schema-level metadata (returned as unmodifiable map)
Outputs
Method Return Type Description
fields() List<LanceField> The list of Lance fields
metadata() Map<String, String> Unmodifiable view of schema metadata
asArrowSchema() Schema Converts to a standard Arrow Schema with all fields and metadata

Usage Examples

// Get the Lance schema from a dataset
LanceSchema lanceSchema = dataset.lanceSchema();

// Access Lance-specific field metadata
for (LanceField field : lanceSchema.fields()) {
    System.out.println("Field: " + field.getName()
        + " (id=" + field.getId()
        + ", type=" + field.getLogicalType() + ")");
}

// Access schema-level metadata
Map<String, String> metadata = lanceSchema.metadata();

// Convert to standard Arrow Schema for interoperability
Schema arrowSchema = lanceSchema.asArrowSchema();

Related Pages

Page Connections

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