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 ColumnCategorical.Builder<String> builder(ColumnName name) Creates a string categorical builder.static <T> ColumnCategorical.Builder<T> builder(ColumnName name, Column.Type type) Creates a categorical builder for the supplied non-primitive type.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.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 set values in 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 Tmax()Returns the maximum set value in the column.default Tmin()Returns the minimum set value in 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, isEmpty, isNoneSet, sizeMethods inherited from interface app.babylon.table.column.ColumnObject
first, getAll, isConstant, isSet, last, toString
-
Method Details
-
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 string categorical builder.- Parameters:
name- column name- Returns:
- categorical builder
-
builder
Creates a categorical builder for the supplied non-primitive type.- Type Parameters:
T- categorical value type- Parameters:
name- column nametype- categorical value type- Returns:
- categorical 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 set values in the column. The null/unset category uses the internal code0, but that code is not exposed by this method. Only codes associated with non-null categorical values are returned.- Parameters:
x- the destination array, ornull- Returns:
- an array of non-zero category codes for set values
-
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
-
max
Description copied from interface:ColumnObjectReturns the maximum set value in the column.- Specified by:
maxin interfaceColumnObject<T>- Returns:
- maximum set value
-
min
Description copied from interface:ColumnObjectReturns the minimum set value in the column.- Specified by:
minin interfaceColumnObject<T>- Returns:
- minimum set value
-
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
-