Package com.lumiomedical.etl.dataframe
Class Tables
java.lang.Object
com.lumiomedical.etl.dataframe.Tables
public final class Tables extends Object
- Author:
- Pierre Lecerf ([email protected]) Created on 2020/08/24
-
Constructor Summary
Constructors Constructor Description Tables()
-
Method Summary
Modifier and Type Method Description static <T, C extends tech.tablesaw.columns.Column<T>>
tech.tablesaw.api.TableaddColumnIfNotExists(tech.tablesaw.api.Table table, String name, ColumnDescriptor<T,C> descriptor)
Adds a column of a given type if it doesn't already exist in the provided table.static boolean
hasColumn(tech.tablesaw.api.Table table, String name)
This is just a shorthand for checking the existence of a column in a table by its name.static <T, C extends tech.tablesaw.columns.Column<T>>
booleanhasColumn(tech.tablesaw.api.Table table, String name, ColumnDescriptor<?,C> descriptor)
-
Constructor Details
-
Tables
public Tables()
-
-
Method Details
-
hasColumn
This is just a shorthand for checking the existence of a column in a table by its name. The List.contains call is O(n) but since we're working on a Table we don't expect there to be more than a handful of dozen columns at the very most. If you do have many more columns in your table, try a different approach ; this method is just here to cover the most common cases.- Parameters:
table
-name
-- Returns:
-
hasColumn
public static <T, C extends tech.tablesaw.columns.Column<T>> boolean hasColumn(tech.tablesaw.api.Table table, String name, ColumnDescriptor<?,C> descriptor)- Parameters:
table
-name
-descriptor
-- Returns:
-
addColumnIfNotExists
public static <T, C extends tech.tablesaw.columns.Column<T>> tech.tablesaw.api.Table addColumnIfNotExists(tech.tablesaw.api.Table table, String name, ColumnDescriptor<T,C> descriptor)Adds a column of a given type if it doesn't already exist in the provided table. If no column exists with the specified name, we create one of the appropriate type. Otherwise, we check if the existing one has the appropriate type, in which case we return it, otherwise we throw an exception.- Type Parameters:
T
-C
-- Parameters:
table
-name
-descriptor
-- Returns:
-