Package io.deephaven.engine.table
Class TableDefinition
java.lang.Object
io.deephaven.engine.table.TableDefinition
- All Implemented Interfaces:
LogOutputAppendable
Table definition for all Deephaven tables.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRuntime exception representing an incompatibility between table definitions. -
Method Summary
Modifier and TypeMethodDescriptioncheckCompatibility(@NotNull TableDefinition other) Test compatibility of this definition with another.checkCompatibility(@NotNull TableDefinition other, boolean ignorePartitioningColumns) Test compatibility of this definition with another.final voidcheckHasColumn(@NotNull String columnName) Check this definition to ensure thatcolumnNameis present.final voidcheckHasColumn(@NotNull String columnName, @NotNull Class<?> clazz) final voidcheckHasColumn(@NotNull String columnName, @NotNull Class<?> clazz, Class<?> componentType) Checks ifcolumnNameexists and supportsColumnDefinition.checkCastTo(Class, Class)withclazzandcomponentType.final voidcheckHasColumns(@NotNull Collection<String> columns) Check this definition to ensure that allcolumnsare present.checkMutualCompatibility(@NotNull TableDefinition other) Tests mutual-compatibility ofthisandother.checkMutualCompatibility(@NotNull TableDefinition other, @NotNull String lhsName, @NotNull String rhsName) Tests mutual-compatibility ofthisandother.describeCompatibilityDifferences(@NotNull TableDefinition other, @NotNull String lhs, @NotNull String rhs) Build a description of the difference between this definition and the other.describeDifferences(@NotNull TableDefinition other, @NotNull String lhs, @NotNull String rhs) Build a description of the difference between this definition and the other.booleanStrict comparison (column-wise only).booleanequalsIgnoreOrder(@NotNull TableDefinition other) Strict comparison (column-wise only).static TableDefinitionfrom(@NotNull Iterable<ColumnHeader<?>> headers) static TableDefinitionConvenience factory method for use with parallel structures of column names and data types.static TableDefinitionConvenience factory method for use with parallel arrays of column names and data types.<T> ColumnDefinition<T>intgetColumnIndex(@NotNull ColumnDefinition<?> column) String[]List<ColumnDefinition<?>>ColumnDefinition<?>[]Class<?>[]getDifferenceDescription(@NotNull TableDefinition other, @NotNull String lhs, @NotNull String rhs, @NotNull String separator) Build a description of the difference between this definition and the other.List<ColumnDefinition<?>>getWritable(boolean partitioningToNormal) inthashCode()static TableDefinitioninferFrom(@NotNull Table sourceTable, @NotNull Map<String, ? extends ColumnSource<?>> newSources) Infer a table definition from the given source table and column sources for a new table.static TableDefinitioninferFrom(@NotNull Map<String, ? extends ColumnSource<?>> sources) intern()InternthisTableDefinition in order to avoid storing many identical instances.intstatic TableDefinitionof(ColumnDefinition<?>... columnDefinitions) static TableDefinitionof(Collection<ColumnDefinition<?>> columnDefinitions) toString()
-
Method Details
-
of
-
of
-
inferFrom
public static TableDefinition inferFrom(@NotNull @NotNull Map<String, ? extends ColumnSource<?>> sources) -
inferFrom
public static TableDefinition inferFrom(@NotNull @NotNull Table sourceTable, @NotNull @NotNull Map<String, ? extends ColumnSource<?>> newSources) Infer a table definition from the given source table and column sources for a new table. Where column sources are identical to those in the source table, the column definition will be identical (except for name); where new sources are encountered, a generic column definition will be inferred.- Parameters:
sourceTable- The source tablenewSources- A map of name to column source for the new table- Returns:
- The inferred table definition
-
from
-
from
public static TableDefinition from(@NotNull @NotNull String[] columnNames, @NotNull @NotNull Class<?>[] columnDataTypes) Convenience factory method for use with parallel arrays of column names and data types. Allcolumn definitionswill have defaultcomponent typeandnormal column type.- Parameters:
columnNames- An array of column names to use, parallel tocolumnDataTypescolumnDataTypes- An array of column data types to use, parallel tocolumnNames- Returns:
- The resulting TableDefinition
-
from
public static TableDefinition from(@NotNull @NotNull Iterable<String> columnNames, @NotNull @NotNull Iterable<Class<?>> columnDataTypes) Convenience factory method for use with parallel structures of column names and data types. Allcolumn definitionswill have defaultcomponent typeandnormal column type.- Parameters:
columnNames- Column names to use, parallel tocolumnDataTypescolumnDataTypes- Column data types to use, parallel tocolumnNames- Returns:
- The resulting TableDefinition
-
intern
InternthisTableDefinition in order to avoid storing many identical instances. Useful (for example) in heavily partitioned workloads.- Returns:
- An interned TableDefinition that is equal to
this
-
toString
-
append
- Specified by:
appendin interfaceLogOutputAppendable
-
numColumns
public int numColumns()- Returns:
- The number of columns for this table definition
-
getColumns
- Returns:
- An unmodifiable list of the column definitions for this table definition
-
getColumnsArray
- Returns:
- An array of the column definitions for this table definition
-
getColumnStream
- Returns:
- A stream of the column definitions for this table definition
-
getColumnNameMap
- Returns:
- An unmodifiable map from column name to column definition
-
getColumnNameSet
- Returns:
- An unmodifiable set of column names
-
getPartitioningColumns
- Returns:
- A list of
column definitionsfor allpartitioningcolumns in the same relative order as the column definitions list
-
getColumnNames
- Returns:
- The column names as a list in the same order as
getColumns()
-
getTypedColumnNames
- Returns:
- The
column namesas a list in the same order asgetColumns()
-
getColumnNamesArray
- Returns:
- The column names as an array in the same order as
getColumns()
-
getColumnTypes
- Returns:
- The column
data typesas a list in the same order asgetColumns()
-
getColumnTypesArray
- Returns:
- The column
data typesas an array in the same order asgetColumns()
-
getColumn
- Type Parameters:
T- The columndata types, as a type parameter- Parameters:
columnName- The column name to search for- Returns:
- The
ColumnDefinitionfor the supplied name, ornullif no such column exists in this table definition
-
getColumnIndex
- Parameters:
column- TheColumnDefinitionto search for- Returns:
- The index of
column, or-1if no such column exists in this table definition - ApiNote:
- This is an O(
numColumns()) lookup.
-
getColumnNamesAsString
- Returns:
- A String of column names joined with
','
-
checkHasColumn
Check this definition to ensure thatcolumnNameis present.- Parameters:
columnName- The column name to check- Throws:
NoSuchColumnException- IfcolumnNameis missing
-
checkHasColumn
public final void checkHasColumn(@NotNull @NotNull String columnName, @NotNull @NotNull Class<?> clazz) Checks ifcolumnNameexists and supportsColumnDefinition.checkCastTo(Class)withclazz. Otherwise, throws aNoSuchColumnExceptionor aClassCastException.- Parameters:
columnName- the column nameclazz- the data type- See Also:
-
checkHasColumn
public final void checkHasColumn(@NotNull @NotNull String columnName, @NotNull @NotNull Class<?> clazz, Class<?> componentType) Checks ifcolumnNameexists and supportsColumnDefinition.checkCastTo(Class, Class)withclazzandcomponentType. Otherwise, throws aNoSuchColumnExceptionor aClassCastException.- Parameters:
columnName- the column nameclazz- the data typecomponentType- the component type- See Also:
-
checkHasColumns
Check this definition to ensure that allcolumnsare present.- Parameters:
columns- The column names to check- Throws:
NoSuchColumnException- If anycolumnswere missing
-
checkMutualCompatibility
Tests mutual-compatibility ofthisandother. To be mutually compatible, they must have the same number of columns, each matched up withColumnDefinition.isCompatible(io.deephaven.engine.table.ColumnDefinition<?>). As such, this method has an equivalence relation, ieA.checkMutualCompatibility(B) == B.checkMutualCompatibility(A).- Parameters:
other- The other definition- Returns:
thistable definition, but in the column order ofother- Throws:
TableDefinition.IncompatibleTableDefinitionException- if the definitions are not compatible
-
checkMutualCompatibility
public TableDefinition checkMutualCompatibility(@NotNull @NotNull TableDefinition other, @NotNull @NotNull String lhsName, @NotNull @NotNull String rhsName) Tests mutual-compatibility ofthisandother. To be mutually compatible, they must have the same number of columns, each matched up withColumnDefinition.isCompatible(io.deephaven.engine.table.ColumnDefinition<?>). As such, this method has an equivalence relation, ieA.checkMutualCompatibility(B) == B.checkMutualCompatibility(A).- Parameters:
other- The other definitionlhsName- Name to use when describingthisif an exception is thrownrhsName- Name to use when describingotherif an exception is thrown- Returns:
thistable definition, but in the column order ofother- Throws:
TableDefinition.IncompatibleTableDefinitionException- if the definitions are not compatible
-
checkCompatibility
Test compatibility of this definition with another. This definition must have all columns of the other, and the column definitions in common must be compatible, as defined byColumnDefinition.isCompatible(ColumnDefinition).Note: unlike
ColumnDefinition.isCompatible(ColumnDefinition), this method does not have an equivalence relation. For a stricter check, usecheckMutualCompatibility(TableDefinition).- Parameters:
other- comparison table definition- Returns:
- the minimized compatible table definition, in the same order as
other - Throws:
TableDefinition.IncompatibleTableDefinitionException- if the definitions are not compatible
-
checkCompatibility
public TableDefinition checkCompatibility(@NotNull @NotNull TableDefinition other, boolean ignorePartitioningColumns) Test compatibility of this definition with another. This definition must have all columns of the other, and the column definitions in common must be compatible, as defined byColumnDefinition.isCompatible(ColumnDefinition).Partitioning columns in other will be ignored if ignorePartitioningColumns is true.
Note: unlike
ColumnDefinition.isCompatible(ColumnDefinition), this method does not have an equivalence relation. For a stricter check, usecheckMutualCompatibility(TableDefinition).- Parameters:
other- comparison table definitionignorePartitioningColumns- if true, other definition may contain partitioning columns not in this definition- Returns:
- the minimized compatible table definition, in the same order as
other - Throws:
TableDefinition.IncompatibleTableDefinitionException- if the definitions are not compatible
-
describeDifferences
public List<String> describeDifferences(@NotNull @NotNull TableDefinition other, @NotNull @NotNull String lhs, @NotNull @NotNull String rhs) Build a description of the difference between this definition and the other. Should correspond toequalsIgnoreOrder(io.deephaven.engine.table.TableDefinition)logic.- Parameters:
other- another TableDefinition to comparelhs- what to call "this" definitionrhs- what to call the other definition- Returns:
- a list of strings representing the difference between two table definitions
-
describeCompatibilityDifferences
public List<String> describeCompatibilityDifferences(@NotNull @NotNull TableDefinition other, @NotNull @NotNull String lhs, @NotNull @NotNull String rhs) Build a description of the difference between this definition and the other. Should correspond tocheckMutualCompatibility(io.deephaven.engine.table.TableDefinition)logic.- Parameters:
other- another TableDefinition to comparelhs- what to call "this" definitionrhs- what to call the other definition- Returns:
- a list of strings representing the difference between two table definitions
-
getDifferenceDescription
public String getDifferenceDescription(@NotNull @NotNull TableDefinition other, @NotNull @NotNull String lhs, @NotNull @NotNull String rhs, @NotNull @NotNull String separator) Build a description of the difference between this definition and the other. Should correspond to equalsIgnoreOrder logic.- Parameters:
other- another TableDefinition to comparelhs- what to call "this" definitionrhs- what to call the other definitionseparator- separate strings in the list of differences with this separator- Returns:
- A string in which the differences are enumerated, separated by the given separator
-
equalsIgnoreOrder
Strict comparison (column-wise only).- Parameters:
other- - The other TableDefinition to compare with.- Returns:
- True if other contains equal ColumnDefinitions in any order. False otherwise.
-
equals
Strict comparison (column-wise only). -
hashCode
public int hashCode() -
getWritable
- Returns:
- This definition if it's writable, or a freshly-allocated definition that is identical but for the columns array, which will exclude all non-writable columns.
-
getWritable
- Parameters:
partitioningToNormal- Whether partitioning columns should be preserved as normal columns, or excluded- Returns:
- This definition if it's writable, or a freshly-allocated definition that is identical but for the columns array, which will exclude all non-writable columns, optionally converting partitioning columns to normal columns.
-