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 ProjectOp

From Leeroopedia
Revision as of 15:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Lance_format_Lance_Java_ProjectOp.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 Project class is an immutable operation that changes the schema of a Lance dataset without modifying the underlying data. It extends SchemaOperation (which implements Operation) and carries only an Arrow Schema as its payload.

Project modifies column positions but does not change field IDs. When columns are removed via a Project operation, the physical data files are not immediately deleted; the data is removed after a subsequent compaction operation. This makes Project a lightweight metadata-only operation.

Usage

Use Project for schema-only transformations such as removing columns (logically), reordering columns, or renaming columns. Since it does not touch data files, it executes quickly regardless of dataset size. Physical cleanup of removed column data occurs during compaction.

Code Reference

Source Location

java/src/main/java/org/lance/operation/Project.java

Signature

public class Project extends SchemaOperation {
    public static Builder builder();
    public Schema schema();       // inherited from SchemaOperation
    public long exportSchema(BufferAllocator allocator); // inherited
    public String name();         // returns "Project"
}

Import

import org.lance.operation.Project;

I/O Contract

Inputs
Parameter Type Required Description
schema org.apache.arrow.vector.types.pojo.Schema Yes The new schema to project the dataset to
Outputs
Return Type Description
schema() Schema The projected schema
exportSchema(allocator) long Memory address of the exported Arrow C schema for JNI
name() String Returns "Project" for JNI dispatch

Usage Examples

// Remove a column by projecting to a schema without it
Schema projectedSchema = new Schema(List.of(
    Field.nullable("id", new ArrowType.Int(64, true)),
    Field.nullable("name", new ArrowType.Utf8())
    // "deprecated_column" is excluded from the projection
));

Project projectOp = Project.builder()
    .schema(projectedSchema)
    .build();

String opName = projectOp.name(); // "Project"

Related Pages

Page Connections

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