Package com.illumon.iris.db.tables
Class TableDefinition
java.lang.Object
com.illumon.dataobjects.generated.DefaultTableDefinition
com.illumon.iris.db.tables.TableDefinition
- All Implemented Interfaces:
com.fishlib.base.Copyable<com.illumon.dataobjects.generated.DefaultTableDefinition>
,com.fishlib.base.log.LogOutputAppendable
,com.fishlib.base.SafeCloneable<com.illumon.dataobjects.generated.DefaultTableDefinition>
,com.fishlib.dataobjects.persistence.WObjectStreamConstants
,com.fishlib.dataobjects.WAbstractDataObject
,Externalizable
,Serializable
,Cloneable
public class TableDefinition
extends com.illumon.dataobjects.generated.DefaultTableDefinition
Table definition for all Deephaven tables.
Adds non-stateful functionality to DefaultTableDefinition.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TableDefinition.IncompatibleTableDefinitionException
Runtime exception representing an incompatibility between table definitions. -
Field Summary
Fields Modifier and Type Field Description static TableDefinition
COLUMN_DEFINITIONS_TABLE_DEFINITION
static String
DEFAULT_FILE_NAME
static String
DEFAULT_FILE_SUFFIX
static com.fishlib.base.formatters.EnumFormatter
STORAGE_TYPE_FORMATTER
Fields inherited from class com.illumon.dataobjects.generated.DefaultTableDefinition
columns, columnSet_, columnSetName_, INDEX_OF_COLUMNS, INDEX_OF_NAME, INDEX_OF_NAMESPACE, INDEX_OF_STORAGETYPE, name, namespace, storageType, STORAGETYPE_INMEMORY, STORAGETYPE_NESTEDPARTITIONEDONDISK, STORAGETYPE_SPLAYEDONDISK
Fields inherited from interface com.fishlib.dataobjects.persistence.WObjectStreamConstants
ADD_CLASS, ADD_COLUMN_SET_CLASS, ADD_ENUM, ADD_ENUM_LONG, ADO_ARRAY_TYPE, ARRAY_TYPE, BOOLEAN_TYPE, BYTE_ARRAY_TYPE, BYTE_TYPE, DATE_TYPE, DOUBLE_ARRAY_TYPE, DOUBLE_TYPE, FLOAT_ARRAY_TYPE, FLOAT_TYPE, INT_ARRAY_TYPE, INTEGER_TYPE, KNOWN_ENUM, KNOWN_ENUM_LONG, LINKED_MAP_TYPE, LINKED_SET_TYPE, LONG_ARRAY_TYPE, LONG_STRING_TYPE, LONG_TYPE, MAP_TYPE, NULL_TYPE, OBJECT_TYPE, SET_TYPE, STRING_ARRAY_TYPE, STRING_TYPE, TREE_MAP_TYPE, TREE_SET_TYPE
-
Constructor Summary
Constructors Constructor Description TableDefinition()
TableDefinition(com.illumon.dataobjects.ColumnDefinition[] columnDefs)
TableDefinition(TableDefinition other)
Creates a partial copy of a TableDefinition.TableDefinition(TableDefinition other, boolean setColumns)
TableDefinition(List<com.illumon.dataobjects.ColumnDefinition> columnDefs)
TableDefinition(List<Class> types, List<String> columnNames)
-
Method Summary
Modifier and Type Method Description com.fishlib.base.log.LogOutput
append(com.fishlib.base.log.LogOutput logOutput)
void
checkCompatibility(TableDefinition other)
Test compatibility of this definition with another.void
checkCompatibility(TableDefinition other, boolean ignorePartitioningColumns)
Test compatibility of this definition with another.static TableDefinition
createUserPartitionedTableDefinition(String partitioningColumnName, TableDefinition baseDefinition)
Helper method to assist with definition creation for user-namespace partitioned tables.static TableDefinition
createUserPartitionedTableDefinition(String partitioningColumnName, TableDefinition baseDefinition, boolean groupingColumnsAsNormal)
Helper method to assist with definition creation for user-namespace partitioned tables.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).com.illumon.dataobjects.ColumnDefinition
getColumn(String columnName)
Table
getColumnDefinitionsTable()
int
getColumnIndex(com.illumon.dataobjects.ColumnDefinition column)
List<com.illumon.dataobjects.ColumnDefinition>
getColumnList()
Map<String,com.illumon.dataobjects.ColumnDefinition>
getColumnNameMap()
List<String>
getColumnNames()
String[]
getColumnNamesArray()
String
getColumnNamesAsString()
Stream<com.illumon.dataobjects.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<com.illumon.dataobjects.ColumnDefinition>
getGroupingColumns()
List<com.illumon.dataobjects.ColumnDefinition>
getPartitioningColumns()
TableDefinition
getWritable()
TableDefinition
getWritable(boolean partitioningToNormal)
com.illumon.dataobjects.ColumnDefinition[]
getWritableColumns(boolean partitioningToNormal)
boolean
isOnDisk()
Deprecated.static boolean
isValidStorageType(int storageType)
static TableDefinition
loadDefinition(File source)
Load a TableDefinition from the supplied file.static TableDefinition
loadDefinition(File sourceDirectory, String tableName)
Load a TableDefinition from the "tableName.tbl" file (given by the tableName parameter), in the specified directory.static TableDefinition
loadDefinition(File sourceDirectory, String tableName, boolean allowMissing)
Load a TableDefinition from the "tableName.tbl" file (given by the tableName parameter), in the specified directory.static TableDefinition
loadDefinitionFromDirectory(File sourceDirectory, String tableName, boolean allowMissing)
Load a TableDefinition from the implementation-defined default definition file in the specified directory.static void
main(String[] args)
static void
persistDefinition(TableDefinition definition, File destination)
Persist the supplied TableDefinition to the supplied file.static void
persistDefinition(TableDefinition definition, File destinationDirectory, String tableName)
Deprecated.This method is for backward compatibility.static void
persistDefinitionToDirectory(TableDefinition definition, File destinationDirectory)
Persist the supplied TableDefinition to the default file for the supplied directory and table name.void
readExternal(ObjectInput in)
void
setColumns(com.illumon.dataobjects.ColumnDefinition[] columns)
void
setStorageType(int storageType)
String
toString()
void
writeExternal(ObjectOutput out)
Methods inherited from class com.illumon.dataobjects.generated.DefaultTableDefinition
clone, copyValues, getByte, getByte, getByte, getColumns, getColumnSet, getColumnSetName, getColumnSetStatic, getDate, getDate, getDate, getDouble, getDouble, getDouble, getInt, getInt, getInt, getLong, getLong, getLong, getName, getNamespace, getStorageType, getString, getString, getString, getValue, getValue, getValue, hashCode, safeClone, setByte, setByte, setDate, setDate, setDouble, setDouble, setInt, setInt, setLong, setLong, setName, setNamespace, setString, setString, setValue, setValue
-
Field Details
-
STORAGE_TYPE_FORMATTER
public static final com.fishlib.base.formatters.EnumFormatter STORAGE_TYPE_FORMATTER -
DEFAULT_FILE_SUFFIX
- See Also:
- Constant Field Values
-
DEFAULT_FILE_NAME
- See Also:
- Constant Field Values
-
COLUMN_DEFINITIONS_TABLE_DEFINITION
-
-
Constructor Details
-
TableDefinition
public TableDefinition() -
TableDefinition
-
TableDefinition
-
TableDefinition
public TableDefinition(@NotNull com.illumon.dataobjects.ColumnDefinition[] columnDefs) -
TableDefinition
Creates a partial copy of a TableDefinition. A new object is created, but the ColumnDefinitions of the new object are the same instances as the ColumnDefinitions in the original (other).- Parameters:
other
- A TableDefinition to partially copy when creating the new definition.
-
TableDefinition
-
-
Method Details
-
toString
- Overrides:
toString
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
-
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput)- Specified by:
append
in interfacecom.fishlib.base.log.LogOutputAppendable
- Overrides:
append
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
-
setColumns
public void setColumns(com.illumon.dataobjects.ColumnDefinition[] columns)- Overrides:
setColumns
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
-
getColumnList
- Returns:
- A list view of the column definition array for this table definition.
-
getColumnStream
- Returns:
- A stream of the column definition array for this table definition
-
getColumnNameMap
- Returns:
- A freshly-allocated, unmodifiable map from column name to column definition.
-
getPartitioningColumns
- Returns:
- A freshly-allocated list of column definitions for all partitioning columns, in the same relative order as in the column definitions array.
-
getGroupingColumns
- Returns:
- A freshly-allocated list of column definitions for all grouping columns, in the same relative order as in the column definitions array.
-
getGroupingColumnNamesArray
- Returns:
- A freshly-allocated array of column names for all grouping columns, in the same relative order as in the column definitions array.
-
getColumnNames
- Returns:
- A freshly-allocated list of column names in the same order as the column definitions array.
-
getColumnNamesArray
- Returns:
- A freshly-allocated array of column names in the same order as the column definitions array.
-
getColumnTypes
- Returns:
- A freshly-allocated list of column types in the same order as the column definitions array.
-
getColumnTypesArray
- Returns:
- A freshly-allocated array of column types in the same order as the column definitions array.
-
getColumn
- Parameters:
columnName
- the column name to search for- Returns:
- The column definition for the supplied name, or null if no such column exists in this table definition.
-
getColumnIndex
public int getColumnIndex(@NotNull com.illumon.dataobjects.ColumnDefinition column)- Parameters:
column
- the ColumnDefinition to search for- Returns:
- The index of the column for the supplied name, or -1 if no such column exists in this table definition. Note: This is an O(columns.length) lookup.
-
getColumnNamesAsString
- Returns:
- A freshly-allocated String of column names joined with ','.
-
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.- Parameters:
other
- comparison table definition- 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. Partitioning columns in other will be ignored if ignorePartitioningColumns is true.- Parameters:
other
- comparison table definitionignorePartitioningColumns
- if true, other definition may contain partitioning columns not in this definition- 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 to equalsIgnoreOrder 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).- Overrides:
equals
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
- Parameters:
other
- - The object to compare with.- Returns:
- True if other is a TableDefinition and contains equal ColumnDefinitions in the same order. False otherwise.
-
isOnDisk
Deprecated. -
setStorageType
public void setStorageType(int storageType)- Overrides:
setStorageType
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
-
isValidStorageType
public static boolean isValidStorageType(int storageType) -
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.
-
getWritableColumns
public com.illumon.dataobjects.ColumnDefinition[] getWritableColumns(boolean partitioningToNormal)- Parameters:
partitioningToNormal
- Whether partitioning columns should be preserved as normal columns, or excluded- Returns:
- This definition's array of column definitions if they're all writable, or a freshly-allocated array of column definitions which will exclude all non-writable columns, optionally converting partitioning columns to normal columns.
-
persistDefinition
public static void persistDefinition(@NotNull TableDefinition definition, @NotNull File destination)Persist the supplied TableDefinition to the supplied file.- Parameters:
definition
- The definitiondestination
- The destination file- Throws:
UncheckedIOException
- if the table definition file could not be written
-
persistDefinition
@Deprecated public static void persistDefinition(@NotNull TableDefinition definition, @NotNull File destinationDirectory, @NotNull String tableName)Deprecated.This method is for backward compatibility.persistDefinition(TableDefinition, File)
orpersistDefinitionToDirectory(TableDefinition, File)
are preferred.Persist the supplied TableDefinition to tableName.tbl (given by the parameter) in the given directory. This directory and file name are not necessarily the ones that will be used by the system.- Parameters:
definition
- The definitiondestinationDirectory
- The destination directorytableName
- The base part of the file name in which to persist the definition
-
persistDefinitionToDirectory
public static void persistDefinitionToDirectory(@NotNull TableDefinition definition, @NotNull File destinationDirectory)Persist the supplied TableDefinition to the default file for the supplied directory and table name. The default definition file is "table.tbl", but this is subject to change.- Parameters:
definition
- The definitiondestinationDirectory
- The destination directory
-
loadDefinition
Load a TableDefinition from the supplied file.- Parameters:
source
- The file to find the definition in- Returns:
- The TableDefinition object
- Throws:
UncheckedIOException
- or other RuntimeException if the file is not found or read fails
-
loadDefinition
public static TableDefinition loadDefinition(@NotNull File sourceDirectory, @NotNull String tableName)Load a TableDefinition from the "tableName.tbl" file (given by the tableName parameter), in the specified directory. This may not be the file name or location used by the system.- Parameters:
sourceDirectory
- The directory to find the definition file intableName
- The table name to use when determining the definition file name- Returns:
- The TableDefinition object
- Throws:
UncheckedIOException
- or other RuntimeException if the file is not found or read fails
-
loadDefinition
@Nullable public static TableDefinition loadDefinition(@NotNull File sourceDirectory, @NotNull String tableName, boolean allowMissing)Load a TableDefinition from the "tableName.tbl" file (given by the tableName parameter), in the specified directory. This may not be the file name or location used by the system.- Parameters:
sourceDirectory
- The directory to find the definition file intableName
- The table name to use when determining the definition file nameallowMissing
- Whether to return null if the file is not found, rather than throwing an exception- Returns:
- The TableDefinition object, or null if not found and
allowMissing
- Throws:
UncheckedIOException
- or other RuntimeException if the file is not found and !allowMissing, or read fails
-
loadDefinitionFromDirectory
@Nullable public static TableDefinition loadDefinitionFromDirectory(@NotNull File sourceDirectory, @NotNull String tableName, boolean allowMissing)Load a TableDefinition from the implementation-defined default definition file in the specified directory. Currently, this will load "table.tbl" in preference to "tableName.tbl", but that behavior is not guaranteed.- Parameters:
sourceDirectory
- The directory to find the definition file intableName
- The table name to use when determining the implementation-defined definition file nameallowMissing
- Whether to return null if the definition is not found, rather than throwing an exception- Returns:
- The TableDefinition object, or null if not found and
allowMissing
- Throws:
UncheckedIOException
- or other RuntimeException if the file is not found and !allowMissing, or read fails
-
getColumnDefinitionsTable
-
createUserPartitionedTableDefinition
public static TableDefinition createUserPartitionedTableDefinition(@NotNull String partitioningColumnName, @NotNull TableDefinition baseDefinition)Helper method to assist with definition creation for user-namespace partitioned tables. This version automatically converts grouping columns to normal columns.- Parameters:
partitioningColumnName
- The name of the column to use for partitioningbaseDefinition
- The definition to work from- Returns:
- A new definition suitable for passing to OnDiskDatabase.addTableDefinition()
-
createUserPartitionedTableDefinition
public static TableDefinition createUserPartitionedTableDefinition(@NotNull String partitioningColumnName, @NotNull TableDefinition baseDefinition, boolean groupingColumnsAsNormal)Helper method to assist with definition creation for user-namespace partitioned tables.- Parameters:
partitioningColumnName
- The name of the column to use for partitioningbaseDefinition
- The definition to work fromgroupingColumnsAsNormal
- Whether grouping columns should be converted to normal columns- Returns:
- A new definition suitable for passing to OnDiskDatabase.addTableDefinition()
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classcom.illumon.dataobjects.generated.DefaultTableDefinition
- Throws:
IOException
-
main
-