Package app.babylon.table.column
Interface ColumnCategorical<T>
- Type Parameters:
T- the runtime value type stored in the column
- All Superinterfaces:
Column,ColumnObject<T>
An object column optimised for repeated values by storing dictionary-encoded
categories.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder for dictionary-encoded categorical columns.Nested classes/interfaces inherited from interface app.babylon.table.column.Column
Column.TypeNested classes/interfaces inherited from interface app.babylon.table.column.ColumnObject
ColumnObject.Mode -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ColumnCategorical.Builder<T> builder(ColumnName name, Column.Type type) static <T> ColumnCategorical.Builder<T> builder(ColumnName name, Class<T> clazz) Creates a categorical column builder for the supplied value class.default intcompare(int i, int j) Compares two row values from this column using the column's ordering semantics.static <T> ColumnCategorical<T> constant(ColumnName name, T value, int size, Column.Type type) Creates a constant categorical column using an explicit column type.static <T> ColumnCategorical<T> constant(ColumnName name, T value, int size, Class<T> valueClass) Creates a constant categorical column with a type inferred from the value class.default ColumnCategorical<T> copy(ColumnName x) Creates a copy of this column with the supplied column name.get(int i) Returns the value at the supplied row.default ColumngetAsColumn(int i) Returns a single-row column containing the value from the supplied row.Appends the distinct categorical values to the supplied collection.intgetCategoryCode(int i) Returns the dictionary code stored at the supplied row.int[]getCategoryCodes(int[] x) Returns the distinct category codes used by the column.getCategoryValue(int categoryCode) Resolves a dictionary code to its categorical value.getUniques(Set<T> x) Collects the distinct set values from the column.default SelectionSelects rows whose values satisfy the supplied predicate.default StringtoString(int i) Formats the value at the supplied row for display.<S> ColumnCategorical<S> transform(Transformer<T, S> transformer) Transforms this categorical column into another categorical column.Returns a projected view of this column using the supplied row mapping.Methods inherited from interface app.babylon.table.column.Column
getName, getType, isAllSet, isNoneSet, sizeMethods inherited from interface app.babylon.table.column.ColumnObject
first, getAll, isConstant, isSet, last, toString
-
Method Details
-
constant
Creates a constant categorical column with a type inferred from the value class.- Type Parameters:
T- the value type- Parameters:
name- the column namevalue- the repeated value, ornullsize- the number of rowsvalueClass- the runtime value class- Returns:
- a constant categorical column
-
constant
Creates a constant categorical column using an explicit column type.- Type Parameters:
T- the value type- Parameters:
name- the column namevalue- the repeated value, ornullsize- the number of rowstype- the column type- Returns:
- a constant categorical column
-
builder
Creates a categorical column builder for the supplied value class.- Type Parameters:
T- the value type- Parameters:
name- the column nameclazz- the runtime value class- Returns:
- a categorical column builder
-
builder
-
get
Description copied from interface:ColumnObjectReturns the value at the supplied row.- Specified by:
getin interfaceColumnObject<T>- Parameters:
i- the zero-based row index- Returns:
- the row value, or
nullwhen unset
-
getCategoryCode
int getCategoryCode(int i) Returns the dictionary code stored at the supplied row.- Parameters:
i- the zero-based row index- Returns:
- the category code for the row
-
getCategoryValue
Resolves a dictionary code to its categorical value.- Parameters:
categoryCode- the dictionary code- Returns:
- the value for that code, or
nullfor the null category
-
getCategoryCodes
int[] getCategoryCodes(int[] x) Returns the distinct category codes used by the column.- Parameters:
x- the destination array, ornull- Returns:
- an array of category codes
-
getCategoricalValues
Appends the distinct categorical values to the supplied collection.- Parameters:
x- the destination collection, ornull- Returns:
- a collection containing the categorical values
-
getUniques
Description copied from interface:ColumnObjectCollects the distinct set values from the column.- Specified by:
getUniquesin interfaceColumnObject<T>- Parameters:
x- the destination set, ornull- Returns:
- a set containing the unique values
-
view
Description copied from interface:ColumnReturns a projected view of this column using the supplied row mapping.- Specified by:
viewin interfaceColumn- Specified by:
viewin interfaceColumnObject<T>- Parameters:
rowIndex- the row mapping to apply- Returns:
- a column view over the selected rows
-
toString
Description copied from interface:ColumnFormats the value at the supplied row for display. -
getAsColumn
Description copied from interface:ColumnReturns a single-row column containing the value from the supplied row.- Specified by:
getAsColumnin interfaceColumn- Parameters:
i- the row to extract- Returns:
- a single-row column with the same column name
-
copy
Description copied from interface:ColumnCreates a copy of this column with the supplied column name. -
compare
default int compare(int i, int j) Description copied from interface:ColumnCompares two row values from this column using the column's ordering semantics. -
select
Description copied from interface:ColumnObjectSelects rows whose values satisfy the supplied predicate.- Specified by:
selectin interfaceColumnObject<T>- Parameters:
f- the predicate to test against each set value- Returns:
- a selection containing the predicate result for each row
-
transform
Transforms this categorical column into another categorical column.- Specified by:
transformin interfaceColumnObject<T>- Type Parameters:
S- the transformed value type- Parameters:
transformer- the transformation to apply- Returns:
- the transformed categorical column
-