Package io.deephaven.engine.table
Class TableDefinition
java.lang.Object
io.deephaven.engine.table.TableDefinition
- All Implemented Interfaces:
LogOutputAppendable
public class TableDefinition extends Object implements LogOutputAppendable
Table definition for all Deephaven tables.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TableDefinition.IncompatibleTableDefinitionException
Runtime exception representing an incompatibility between table definitions. -
Method Summary
Modifier and Type Method Description LogOutput
append(LogOutput logOutput)
TableDefinition
checkCompatibility(TableDefinition other)
Test compatibility of this definition with another.TableDefinition
checkCompatibility(TableDefinition other, boolean ignorePartitioningColumns)
Test compatibility of this definition with another.TableDefinition
checkMutualCompatibility(TableDefinition other)
Tests mutual-compatibility ofthis
andother
.TableDefinition
checkMutualCompatibility(TableDefinition other, String lhsName, String rhsName)
Tests mutual-compatibility ofthis
andother
.List<String>
describeCompatibilityDifferences(TableDefinition other, String lhs, String rhs)
Build a description of the difference between this definition and the other.List<String>
describeDifferences(TableDefinition other, String lhs, String rhs)
Build a description of the difference between this definition and the other.boolean
equals(Object other)
Strict comparison (column-wise only).boolean
equalsIgnoreOrder(TableDefinition other)
Strict comparison (column-wise only).static TableDefinition
from(Iterable<ColumnHeader<?>> headers)
static TableDefinition
from(Iterable<String> columnNames, Iterable<Class<?>> columnDataTypes)
Convenience factory method for use with parallel structures of column names and data types.static TableDefinition
from(String[] columnNames, Class<?>[] columnDataTypes)
Convenience factory method for use with parallel arrays of column names and data types.<T> ColumnDefinition<T>
getColumn(String columnName)
int
getColumnIndex(ColumnDefinition<?> column)
Map<String,ColumnDefinition<?>>
getColumnNameMap()
List<String>
getColumnNames()
String[]
getColumnNamesArray()
String
getColumnNamesAsString()
List<ColumnDefinition<?>>
getColumns()
ColumnDefinition<?>[]
getColumnsArray()
Stream<ColumnDefinition<?>>
getColumnStream()
List<Class<?>>
getColumnTypes()
Class<?>[]
getColumnTypesArray()
String
getDifferenceDescription(TableDefinition other, String lhs, String rhs, String separator)
Build a description of the difference between this definition and the other.String[]
getGroupingColumnNamesArray()
List<ColumnDefinition<?>>
getGroupingColumns()
List<ColumnDefinition<?>>
getPartitioningColumns()
List<ColumnName>
getTypedColumnNames()
TableDefinition
getWritable()
TableDefinition
getWritable(boolean partitioningToNormal)
int
hashCode()
static TableDefinition
inferFrom(Map<String,? extends ColumnSource<?>> sources)
TableDefinition
intern()
Internthis
TableDefinition in order to avoid storing many identical instances.int
numColumns()
static TableDefinition
of(ColumnDefinition<?>... columnDefinitions)
static TableDefinition
of(Collection<ColumnDefinition<?>> columnDefinitions)
String
toString()
-
Method Details
-
of
-
of
-
inferFrom
-
from
-
from
public static TableDefinition from(@NotNull String[] columnNames, @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 Iterable<String> columnNames, @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
-
getPartitioningColumns
- Returns:
- A list of
column definitions
for allpartitioning
columns in the same relative order as the column definitions list
-
getGroupingColumns
- Returns:
- A list of
column definitions
for allgrouping
columns in the same relative order as the column definitions list
-
getGroupingColumnNamesArray
- Returns:
- An array containing the names of all
grouping
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
','
-
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 TableDefinition other, @NotNull String lhsName, @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 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 TableDefinition other, @NotNull String lhs, @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 TableDefinition other, @NotNull String lhs, @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 TableDefinition other, @NotNull String lhs, @NotNull String rhs, @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.
-