Class ProjectedSchema
java.lang.Object
dev.hardwood.schema.ProjectedSchema
Represents a projected view of a Parquet schema containing only selected columns.
This class handles the mapping between projected column indices (dense, 0-based) and original column indices, allowing the reader to skip I/O, decoding, and memory allocation for non-projected columns.
For nested schemas, projecting a parent group includes all its child columns. For example, if "address" is a struct containing "city" and "street", projecting "address" includes both child columns.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProjectedSchemacreate(FileSchema schema, ColumnProjection projection) Creates a projected schema from the given full schema and projection.Returns the original file schema.getProjectedColumn(int projectedIndex) Returns the projected column at the given projected index.intReturns the number of projected columns.Returns the list of projected columns.int[]Returns the indices of projected top-level fields in the root node's children.booleanReturns true if all columns are projected.inttoOriginalIndex(int projectedIndex) Converts a projected column index to the original column index.inttoProjectedIndex(int originalIndex) Converts an original column index to the projected column index.
-
Method Details
-
create
Creates a projected schema from the given full schema and projection.- Parameters:
schema- the original file schemaprojection- the column projection specifying which columns to include- Returns:
- a projected schema containing only the selected columns
- Throws:
IllegalArgumentException- if a projected column name is not found in the schema
-
getOriginalSchema
Returns the original file schema. -
getProjectedColumnCount
public int getProjectedColumnCount()Returns the number of projected columns. -
toOriginalIndex
public int toOriginalIndex(int projectedIndex) Converts a projected column index to the original column index.- Parameters:
projectedIndex- the index in the projected schema (0-based)- Returns:
- the corresponding index in the original schema
- Throws:
IndexOutOfBoundsException- if projectedIndex is out of range
-
toProjectedIndex
public int toProjectedIndex(int originalIndex) Converts an original column index to the projected column index.- Parameters:
originalIndex- the index in the original schema- Returns:
- the corresponding index in the projected schema, or -1 if not projected
-
getProjectedColumns
Returns the list of projected columns. -
getProjectedColumn
Returns the projected column at the given projected index. -
getProjectedFieldIndices
public int[] getProjectedFieldIndices()Returns the indices of projected top-level fields in the root node's children. This is used by NestedBatchDataView to build a sparse record structure. -
projectsAll
public boolean projectsAll()Returns true if all columns are projected.
-