Package app.babylon.table.column
Class Columns
java.lang.Object
app.babylon.table.column.Columns
Utility methods for common column construction, conversion, aggregation, and
reshaping operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleaggregate(ColumnDouble cd, Aggregate aggregate) Computes an aggregate over a double column.static BigDecimalaggregate(ColumnObject<BigDecimal> cd, Aggregate aggregate) Computes an aggregate over a decimal column.static ColumnObject<String> asStringColumn(Column column) Casts a generic column to a string column.static ColumnConcatenates multiple columns of the same logical type.frequencyMap(ColumnObject<T> c) Builds a frequency map of set values in an object column.static booleanReturns whether the column has no rows.static booleanisStringColumn(Column column) Returns whether the column stores strings.static <T> Tmax(ColumnObject<T> co) Returns the maximum set value in an object column.static <T> Tmin(ColumnObject<T> co) Returns the minimum set value in an object column.static Column.BuildernewBuilder(ColumnName colName, Column.Type type) Creates a builder suitable for the supplied type.static ColumnBytenewByte(ColumnName colName, byte value, int size) Creates a constant byte column.static <T> ColumnCategorical<T> newCategorical(ColumnName colName, T value, int size, Column.Type type) Creates a constant categorical column.static Column.BuildernewColumn(ColumnName colName) Creates a default string column builder.static ColumnObject<BigDecimal> newDecimal(ColumnName colName, BigDecimal value, int size) Creates a constant decimal column.static ColumnDoublenewDouble(ColumnName colName, double value, int size) Creates a constant double column.static ColumnIntnewInt(ColumnName colName, int value, int size) Creates a constant int column.static ColumnObject<String> newString(ColumnName colName, String value, int size) Creates a constant string column.static ColumnObject<String> newStringView(ColumnObject<String> c, ViewIndex rowIndex) Returns a string-column view.Returns a row view of the supplied column.static ColumnReturns a sorted view using the column's natural row comparison.static Columnsort(Column column, ComparatorInt comparator) Returns a sorted view using the supplied row comparator.static ColumnObject<BigDecimal> stringToDecimal(Column column) Converts a string column to decimals.static <S> ColumnObject<S> stringToType(Column column, Function<String, S> parser, Column.Type targetType) Converts a string column to another object type using the supplied parser.static StringReturns a short preview string for a column.
-
Method Details
-
isStringColumn
Returns whether the column stores strings.- Parameters:
column- column to inspect- Returns:
truewhen the column is a string object column
-
asStringColumn
Casts a generic column to a string column.- Parameters:
column- column to cast- Returns:
- string column view
-
frequencyMap
Builds a frequency map of set values in an object column.- Type Parameters:
T- value type- Parameters:
c- source column- Returns:
- value frequency map
-
stringToType
public static <S> ColumnObject<S> stringToType(Column column, Function<String, S> parser, Column.Type targetType) Converts a string column to another object type using the supplied parser.- Type Parameters:
S- target value type- Parameters:
column- source columnparser- string parsertargetType- target type- Returns:
- converted column or
null
-
stringToDecimal
Converts a string column to decimals.- Parameters:
column- source column- Returns:
- decimal column or
null
-
isEmpty
Returns whether the column has no rows.- Parameters:
column- column to inspect- Returns:
truewhen empty
-
newColumn
Creates a default string column builder.- Parameters:
colName- column name- Returns:
- new builder
-
newBuilder
Creates a builder suitable for the supplied type.- Parameters:
colName- column nametype- target type- Returns:
- new builder
-
newDecimal
Creates a constant decimal column.- Parameters:
colName- column namevalue- constant valuesize- row count- Returns:
- constant decimal column
-
newInt
Creates a constant int column. -
newByte
Creates a constant byte column. -
newString
Creates a constant string column. -
newCategorical
public static <T> ColumnCategorical<T> newCategorical(ColumnName colName, T value, int size, Column.Type type) Creates a constant categorical column. -
aggregate
Computes an aggregate over a decimal column. -
max
Returns the maximum set value in an object column. -
min
Returns the minimum set value in an object column. -
aggregate
Computes an aggregate over a double column. -
newDouble
Creates a constant double column. -
newView
Returns a row view of the supplied column. -
sort
Returns a sorted view using the column's natural row comparison. -
sort
Returns a sorted view using the supplied row comparator. -
newStringView
Returns a string-column view. -
concat
Concatenates multiple columns of the same logical type. -
toString
Returns a short preview string for a column.
-