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
Modifier and TypeClassDescriptionstatic class
Runtime 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 void
checkHasColumn
(@NotNull String columnName) Check this definition to ensure thatcolumnName
is present.final void
checkHasColumn
(@NotNull String columnName, @NotNull Class<?> clazz) final void
checkHasColumn
(@NotNull String columnName, @NotNull Class<?> clazz, Class<?> componentType) Checks ifcolumnName
exists and supportsColumnDefinition.checkCastTo(Class, Class)
withclazz
andcomponentType
.final void
checkHasColumns
(@NotNull Collection<String> columns) Check this definition to ensure that allcolumns
are present.checkMutualCompatibility
(@NotNull TableDefinition other) Tests mutual-compatibility ofthis
andother
.checkMutualCompatibility
(@NotNull TableDefinition other, @NotNull String lhsName, @NotNull String rhsName) Tests mutual-compatibility ofthis
andother
.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.boolean
Strict comparison (column-wise only).boolean
equalsIgnoreOrder
(@NotNull TableDefinition other) Strict comparison (column-wise only).static TableDefinition
from
(@NotNull Iterable<ColumnHeader<?>> headers) static TableDefinition
Convenience factory method for use with parallel structures of column names and data types.static TableDefinition
Convenience factory method for use with parallel arrays of column names and data types.<T> ColumnDefinition<T>
int
getColumnIndex
(@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) int
hashCode()
static TableDefinition
inferFrom
(@NotNull Map<String, ? extends ColumnSource<?>> sources) intern()
Internthis
TableDefinition in order to avoid storing many identical instances.int
static TableDefinition
of
(ColumnDefinition<?>... columnDefinitions) static TableDefinition
of
(Collection<ColumnDefinition<?>> columnDefinitions) toString()
-
Method Details
-
of
-
of
-
inferFrom
public static TableDefinition inferFrom(@NotNull @NotNull Map<String, ? extends ColumnSource<?>> sources) -
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 definitions
will have defaultcomponent type
andnormal column type
.- Parameters:
columnNames
- An array of column names to use, parallel tocolumnDataTypes
columnDataTypes
- 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 definitions
will have defaultcomponent type
andnormal column type
.- Parameters:
columnNames
- Column names to use, parallel tocolumnDataTypes
columnDataTypes
- Column data types to use, parallel tocolumnNames
- Returns:
- The resulting TableDefinition
-
intern
Internthis
TableDefinition 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:
append
in 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 definitions
for allpartitioning
columns 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 names
as 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 types
as a list in the same order asgetColumns()
-
getColumnTypesArray
- Returns:
- The column
data types
as 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
ColumnDefinition
for the supplied name, ornull
if no such column exists in this table definition
-
getColumnIndex
- Parameters:
column
- TheColumnDefinition
to search for- Returns:
- The index of
column
, or-1
if 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 thatcolumnName
is present.- Parameters:
columnName
- The column name to check- Throws:
NoSuchColumnException
- IfcolumnName
is missing
-
checkHasColumn
public final void checkHasColumn(@NotNull @NotNull String columnName, @NotNull @NotNull Class<?> clazz) Checks ifcolumnName
exists and supportsColumnDefinition.checkCastTo(Class)
withclazz
. Otherwise, throws aNoSuchColumnException
or 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 ifcolumnName
exists and supportsColumnDefinition.checkCastTo(Class, Class)
withclazz
andcomponentType
. Otherwise, throws aNoSuchColumnException
or aClassCastException
.- Parameters:
columnName
- the column nameclazz
- the data typecomponentType
- the component type- See Also:
-
checkHasColumns
Check this definition to ensure that allcolumns
are present.- Parameters:
columns
- The column names to check- Throws:
NoSuchColumnException
- If anycolumns
were missing
-
checkMutualCompatibility
Tests mutual-compatibility ofthis
andother
. 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:
this
table 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 ofthis
andother
. 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 describingthis
if an exception is thrownrhsName
- Name to use when describingother
if an exception is thrown- Returns:
this
table 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.
-