Class TableTools
public class TableTools extends Object
-
Field Summary
Fields Modifier and Type Field Description static String
NULL_STRING
-
Constructor Summary
Constructors Constructor Description TableTools()
-
Method Summary
Modifier and Type Method Description static String
base64Fingerprint(Table source)
Compute the SHA256 hash of the input table and return it in base64 string format.static ColumnHolder
byteCol(String name, byte... data)
Returns a ColumnHolder of type byte that can be used when creating in-memory tables.static ColumnHolder
charCol(String name, char... data)
Returns a ColumnHolder of type char that can be used when creating in-memory tables.static <T> ColumnHolder
col(String name, T... data)
Returns a ColumnHolder that can be used when creating in-memory tables.static ColumnSource<Byte>
colSource(byte... values)
Creates an in-memory column of type byte for a collection of values.static ColumnSource<Character>
colSource(char... values)
Creates an in-memory column of type char for a collection of values.static ColumnSource<Double>
colSource(double... values)
Creates an in-memory column of type double for a collection of values.static ColumnSource<Float>
colSource(float... values)
Creates an in-memory column of type float for a collection of values.static ColumnSource<Integer>
colSource(int... values)
Creates an in-memory column of type int for a collection of values.static ColumnSource<Long>
colSource(long... values)
Creates an in-memory column of type long for a collection of values.static ColumnSource<Short>
colSource(short... values)
Creates an in-memory column of type short for a collection of values.static <T> ColumnSource<T>
colSource(Class<T> clazz, Collection<T> values)
Creates an in-memory column of the specified type for a collection of values.static byte[]
computeFingerprint(Table source)
Compute the SHA256 hash of the input table.static String
diff(Table actualResult, Table expectedResult, long maxDiffLines)
Computes the difference of two tables for use in verification.static String
diff(Table actualResult, Table expectedResult, long maxDiffLines, EnumSet<TableDiff.DiffItems> itemsToSkip)
Computes the difference of two tables for use in verification.static com.fishlib.base.Pair<String,Long>
diffPair(Table actualResult, Table expectedResult, long maxDiffLines, EnumSet<TableDiff.DiffItems> itemsToSkip)
Computes the difference of two tables for use in verification.static JFrame
display(Table source, boolean shutdownProcessOnClose, String... columns)
Deprecated.static JFrame
display(Table source, boolean shutdownProcessOnClose, Map<String,Format> formatters, String... columns)
Deprecated.static JFrame
display(Table source, String... columns)
Deprecated.static JFrame
display(Table source, Map<String,Format> formatters, String... columns)
Deprecated.static ColumnHolder
doubleCol(String name, double... data)
Returns a ColumnHolder of type double that can be used when creating in-memory tables.static Table
emptyTable(long size)
Returns a new, empty Deephaven Table.static Table
emptyTable(long size, TableDefinition tableDefinition)
Returns a new, empty Deephaven Table.static ColumnHolder
floatCol(String name, float... data)
Returns a ColumnHolder of type float that can be used when creating in-memory tables.static Object
getKey(ColumnSource[] groupByColumnSources, long row)
Returns a SmartKey for the specified row from a set of ColumnSources.static Object
getPrevKey(ColumnSource[] groupByColumnSources, long row)
Returns a SmartKey for the row previous to the specified row from a set of ColumnSources.static String
html(Table source)
Returns a printout of a table formatted as HTML.static ColumnHolder
intCol(String name, int... data)
Returns a ColumnHolder of type int that can be used when creating in-memory tables.static ColumnHolder
longCol(String name, long... data)
Returns a ColumnHolder of type long that can be used when creating in-memory tables.static Table
merge(Table... tables)
Concatenates multiple Deephaven Tables into a single Table.static Table
merge(Collection<Table> tables)
Concatenates multiple Deephaven Tables into a single Table.static Table
merge(List<Table> theList)
Concatenates multiple Deephaven Tables into a single Table.static Table
mergeSorted(String keyColumn, Table... tables)
Concatenates multiple sorted Deephaven Tables into a single Table sorted by the specified key column.static Table
mergeSorted(String keyColumn, Collection<Table> tables)
Concatenates multiple sorted Deephaven Tables into a single Table sorted by the specified key column.static DynamicTable
newTable(long size, List<String> names, List<ColumnSource> columnSources)
Creates a new DynamicTable.static DynamicTable
newTable(long size, Map<String,ColumnSource> columns)
Creates a new DynamicTable.static DynamicTable
newTable(TableDefinition definition)
Creates a new DynamicTable.static DynamicTable
newTable(TableDefinition tDef, ColumnHolder... columnHolders)
Creates a new DynamicTable.static DynamicTable
newTable(ColumnHolder... columnHolders)
Creates a new DynamicTable.static <T> ColumnSource
objColSource(T... values)
Creates an in-memory column of the specified type for a collection of valuesstatic Table
readBin(TableKey key, File... sourceFiles)
Loads a binary log file as an in-memory DB table.static Table
readBin(String namespace, String tableName, TableDefinition tableDefinition, File... sourceFiles)
Loads a binary log file as an in-memory DB table.static Table
readBin(String namespace, String tableName, TableType tableType, File... sourceFiles)
Loads a binary log file as an in-memory DB table.static Table
readBin(String namespace, String tableName, File... sourceFiles)
Loads a binary log file as an in-memory DB table.static Table
readBin(String namespace, String tableName, File sourceDirectory, String sourceFileNameGlob)
Loads a binary log file as an in-memory DB table.static Table
readBin(String namespace, String tableName, String... sourceFiles)
Loads a binary log file as an in-memory DB table.static Table
readCsv(File file)
Returns a memory table created from importing CSV data.static Table
readCsv(File file, StatusCallback progress)
Returns a memory table created from importing CSV data.static Table
readCsv(File file, String format, StatusCallback progress)
Returns a memory table created from importing CSV data.static DynamicTable
readCsv(InputStream is)
Returns a memory table created from importing CSV data.static DynamicTable
readCsv(InputStream is, char separator)
Returns a memory table created from importing CSV data.static Table
readCsv(String filePath)
Returns a memory table created from importing CSV data.static Table
readCsv(String filePath, String format)
Returns a memory table created from importing CSV data.static Table
readCsv(String filePath, String format, StatusCallback progress)
Returns a memory table created from importing CSV data.static Table
readHeaderlessCsv(File file, String format, StatusCallback progress, Collection<String> header)
Returns a memory table created from importing CSV data.static Table
readHeaderlessCsv(String filePath)
Returns a memory table created from importing CSV data.static Table
readHeaderlessCsv(String filePath, String... header)
Returns a memory table created from importing CSV data.static Table
readHeaderlessCsv(String filePath, String format, StatusCallback progress, Collection<String> header)
Returns a memory table created from importing CSV data.static Table
readHeaderlessCsv(String filePath, Collection<String> header)
Returns a memory table created from importing CSV data.static Table
roundDecimalColumns(Table table)
Produce a new table with all the columns of this table, in the same order, but withdouble
andfloat
columns rounded tolong
s.static Table
roundDecimalColumns(Table table, String... columns)
Produce a new table with all the columns of this table, in the same order, but withdouble
andfloat
columns rounded tolong
s.static Table
roundDecimalColumnsExcept(Table table, String... columnsNotToRound)
Produce a new table with all the columns of this table, in the same order, but with alldouble
andfloat
columns rounded tolong
s, except for the specifiedcolumnsNotToRound
.static ColumnHolder
shortCol(String name, short... data)
Returns a ColumnHolder of type short that can be used when creating in-memory tables.static void
show(Table source, long maxRowCount, DBTimeZone timeZone, PrintStream out, String... columns)
Prints the first few rows of a table to standard output.static void
show(Table source, long maxRowCount, DBTimeZone timeZone, String... columns)
Prints the first few rows of a table to standard output.static void
show(Table source, long maxRowCount, DBTimeZone timeZone, String delimiter, PrintStream out, boolean showIndex, String... columns)
Prints the first few rows of a table to standard output.static void
show(Table source, long maxRowCount, String... columns)
Prints the first few rows of a table to standard output.static void
show(Table source, DBTimeZone timeZone, String... columns)
Prints the first few rows of a table to standard output.static void
show(Table source, String... columns)
Prints the first few rows of a table to standard output.static void
showCommaDelimited(Table source, long maxRowCount, String... columns)
Prints the first few rows of a table to standard output, with commas between values.static void
showCommaDelimited(Table source, String... columns)
Prints the first few rows of a table to standard output, with commas between values.static void
showWithIndex(Table source, long firstRow, long lastRow, PrintStream out, String... columns)
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.static void
showWithIndex(Table source, long firstRow, long lastRow, String... columns)
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.static void
showWithIndex(Table source, long maxRowCount, DBTimeZone timeZone, PrintStream out, String... columns)
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.static void
showWithIndex(Table source, long maxRowCount, String... columns)
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.static void
showWithIndex(Table source, String... columns)
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.static String
string(Table t, int size, DBTimeZone timeZone, String... columns)
Returns the first few rows of a table as a pipe-delimited string.static String
string(Table t, int size, String... columns)
Returns the first few rows of a table as a pipe-delimited string.static String
string(Table t, DBTimeZone timeZone, String... columns)
Returns the first few rows of a table as a pipe-delimited string.static String
string(Table t, String... columns)
Returns the first few rows of a table as a pipe-delimited string.static ColumnHolder
stringCol(String name, String... data)
Returns a ColumnHolder of type String that can be used when creating in-memory tables.static String
stringWithIndex(Table t, int size, String... columns)
static Table
timeTable(long periodNanos)
Creates a table that adds a new row on a regular interval.static Table
timeTable(long periodNanos, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static Table
timeTable(DBDateTime startTime, long periodNanos)
Creates a table that adds a new row on a regular interval.static Table
timeTable(DBDateTime startTime, long periodNanos, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static Table
timeTable(DBDateTime startTime, String period)
Creates a table that adds a new row on a regular interval.static Table
timeTable(DBDateTime startTime, String period, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String period)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String startTime, long periodNanos)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String startTime, long periodNanos, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String period, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String startTime, String period)
Creates a table that adds a new row on a regular interval.static Table
timeTable(String startTime, String period, ReplayerInterface replayer)
Creates a table that adds a new row on a regular interval.static void
writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, char fieldSeparator, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, boolean compressed, String destPath, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, boolean compressed, String destPath, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, PrintStream out, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, PrintStream out, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, boolean nullsAsEmpty, char separator, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, String destPath, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(Table source, String destPath, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(String sourcePath, String destPath, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(String sourcePath, String destPath, DBTimeZone timeZone, boolean nullsAsEmpty, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(String sourcePath, String destPath, DBTimeZone timeZone, String... columns)
Writes a DB table out as a CSV.static void
writeCsv(String sourcePath, String destPath, String... columns)
Writes a DB table out as a CSV.
-
Field Details
-
NULL_STRING
- See Also:
- Constant Field Values
-
-
Constructor Details
-
TableTools
public TableTools()
-
-
Method Details
-
show
Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objectcolumns
- varargs of column names to display
-
showWithIndex
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.- Parameters:
source
- a Deephaven table objectcolumns
- varargs of column names to display
-
showCommaDelimited
Prints the first few rows of a table to standard output, with commas between values.- Parameters:
source
- a Deephaven table objectcolumns
- varargs of column names to display
-
show
Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objecttimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- varargs of column names to display
-
show
Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returncolumns
- varargs of column names to display
-
showWithIndex
Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returncolumns
- varargs of column names to display
-
showCommaDelimited
Prints the first few rows of a table to standard output, with commas between values.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returncolumns
- varargs of column names to display
-
show
public static void show(@NotNull Table source, long maxRowCount, DBTimeZone timeZone, String... columns)Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returntimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- varargs of column names to display
-
show
public static void show(@NotNull Table source, long maxRowCount, DBTimeZone timeZone, PrintStream out, String... columns)Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returntimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedout
- a PrintStream destination to which to print the datacolumns
- varargs of column names to display
-
showWithIndex
public static void showWithIndex(@NotNull Table source, long maxRowCount, DBTimeZone timeZone, PrintStream out, String... columns)Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returntimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedout
- a PrintStream destination to which to print the datacolumns
- varargs of column names to display
-
showWithIndex
public static void showWithIndex(@NotNull Table source, long firstRow, long lastRow, PrintStream out, String... columns)Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.- Parameters:
source
- a Deephaven table objectfirstRow
- the firstRow to displaylastRow
- the lastRow (exclusive) to displayout
- a PrintStream destination to which to print the datacolumns
- varargs of column names to display
-
show
public static void show(@NotNull Table source, long maxRowCount, DBTimeZone timeZone, String delimiter, PrintStream out, boolean showIndex, String... columns)Prints the first few rows of a table to standard output.- Parameters:
source
- a Deephaven table objectmaxRowCount
- the number of rows to returntimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjusteddelimiter
- a String value to use between printed valuesout
- a PrintStream destination to which to print the datashowIndex
- a boolean indicating whether to also print index detailscolumns
- varargs of column names to display
-
showWithIndex
public static void showWithIndex(@NotNull Table source, long firstRow, long lastRow, String... columns)Prints the first few rows of a table to standard output, and also prints the details of the index and record positions that provided the values.- Parameters:
source
- a Deephaven table objectfirstRow
- the firstRow to displaylastRow
- the lastRow (exclusive) to displaycolumns
- varargs of column names to display
-
display
Deprecated. -
display
@Deprecated public static JFrame display(Table source, boolean shutdownProcessOnClose, String... columns)Deprecated. -
display
@Deprecated public static JFrame display(Table source, Map<String,Format> formatters, String... columns)Deprecated. -
display
@Deprecated public static JFrame display(Table source, boolean shutdownProcessOnClose, Map<String,Format> formatters, String... columns)Deprecated. -
string
Returns the first few rows of a table as a pipe-delimited string.- Parameters:
t
- a Deephaven table objectcolumns
- varargs of columns to include in the result- Returns:
- a String
-
string
Returns the first few rows of a table as a pipe-delimited string.- Parameters:
t
- a Deephaven table objectsize
- the number of rows to returncolumns
- varargs of columns to include in the result- Returns:
- a String
-
stringWithIndex
-
string
Returns the first few rows of a table as a pipe-delimited string.- Parameters:
t
- a Deephaven table objecttimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- varargs of columns to include in the result- Returns:
- a String
-
string
Returns the first few rows of a table as a pipe-delimited string.- Parameters:
t
- a Deephaven table objectsize
- the number of rows to returntimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- varargs of columns to include in the result- Returns:
- a String
-
html
Returns a printout of a table formatted as HTML. Limit use to small tables to avoid running out of memory.- Parameters:
source
- a Deephaven table object- Returns:
- a String of the table printout formatted as HTML
-
diff
Computes the difference of two tables for use in verification.- Parameters:
actualResult
- first Deephaven table object to compareexpectedResult
- second Deephaven table object to comparemaxDiffLines
- stop comparing after this many differences are found- Returns:
- String report of the detected differences
-
diff
public static String diff(Table actualResult, Table expectedResult, long maxDiffLines, EnumSet<TableDiff.DiffItems> itemsToSkip)Computes the difference of two tables for use in verification.- Parameters:
actualResult
- first Deephaven table object to compareexpectedResult
- second Deephaven table object to comparemaxDiffLines
- stop comparing after this many differences are founditemsToSkip
- EnumSet of checks not to perform, such as checking column order, or exact match of double values- Returns:
- String report of the detected differences
-
diffPair
public static com.fishlib.base.Pair<String,Long> diffPair(Table actualResult, Table expectedResult, long maxDiffLines, EnumSet<TableDiff.DiffItems> itemsToSkip)Computes the difference of two tables for use in verification.- Parameters:
actualResult
- first Deephaven table object to compareexpectedResult
- second Deephaven table object to comparemaxDiffLines
- stop comparing after this many differences are founditemsToSkip
- EnumSet of checks not to perform, such as checking column order, or exact match of double values- Returns:
- a pair of String report of the detected differences, and the first different row (0 if there are no different data values)
-
readBin
public static Table readBin(@NotNull String namespace, @NotNull String tableName, @NotNull File sourceDirectory, @NotNull String sourceFileNameGlob)Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
namespace
- namespace to search for the Listener needed to import the datatableName
- table name to find for the Listener needed to import the datasourceDirectory
- file system path of the log filesourceFileNameGlob
- file pattern to use to find log file(s) to import- Returns:
- a Deephaven table object
-
readBin
public static Table readBin(@NotNull String namespace, @NotNull String tableName, String... sourceFiles)Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
namespace
- namespace to search for the Listener needed to import the datatableName
- table name to find for the Listener needed to import the datasourceFiles
- list of names of files to import- Returns:
- a Deephaven table object
-
readBin
@ScriptApi public static Table readBin(@NotNull String namespace, @NotNull String tableName, File... sourceFiles)Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
namespace
- namespace to search for the Listener needed to import the datatableName
- table name to find for the Listener needed to import the datasourceFiles
- list of File objects to import- Returns:
- a Deephaven table object
-
readBin
public static Table readBin(@NotNull String namespace, @NotNull String tableName, @NotNull TableType tableType, File... sourceFiles)Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
namespace
- namespace to search for the Listener needed to import the datatableName
- table name to find for the Listener needed to import the datatableType
- table type this table definitionsourceFiles
- list of File objects to import- Returns:
- a Deephaven table object
- Throws:
SchemaException
- if the table definition is not found or if the table type doesn't match
-
readBin
public static Table readBin(@NotNull String namespace, @NotNull String tableName, @NotNull TableDefinition tableDefinition, File... sourceFiles)Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
namespace
- namespace to search for the Listener needed to import the datatableName
- table name to find for the Listener needed to import the datatableDefinition
- use this table definition rather than looking one upsourceFiles
- list of File objects to import- Returns:
- a Deephaven table object
-
readBin
Loads a binary log file as an in-memory DB table. Requires access to the listener class that matches the file to be loaded.- Parameters:
key
- Interface that specifies key fields for a table-keyed object.sourceFiles
- list of File objects to import- Returns:
- a Deephaven table object
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
is
- an InputStream providing access to the CSV data.- Returns:
- a Deephaven DynamicTable object
- Throws:
IOException
- if the InputStream cannot be read
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
is
- an InputStream providing access to the CSV data.separator
- a char to use as the delimiter value when parsing the file.- Returns:
- a Deephaven DynamicTable object
- Throws:
IOException
- if the InputStream cannot be read
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.format
- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readCsv
@ScriptApi public static Table readCsv(String filePath, String format, StatusCallback progress) throws IOExceptionReturns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.format
- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
file
- a file object providing access to the CSV file to be read.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readCsv
Returns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
file
- a file object providing access to the CSV file to be read.progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readCsv
@ScriptApi public static Table readCsv(File file, String format, StatusCallback progress) throws IOExceptionReturns a memory table created from importing CSV data. The first row must be column names. Column data types are inferred from the data.- Parameters:
file
- a file object providing access to the CSV file to be read.format
- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readHeaderlessCsv
Returns a memory table created from importing CSV data. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(String filePath, Collection<String> header) throws IOExceptionReturns a memory table created from importing CSV data. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.header
- Column names to use for the resultant table.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(String filePath, String... header) throws IOExceptionReturns a memory table created from importing CSV data. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.header
- Column names to use for the resultant table.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(String filePath, String format, StatusCallback progress, Collection<String> header) throws IOExceptionReturns a memory table created from importing CSV data. Column data types are inferred from the data.- Parameters:
filePath
- the fully-qualified path to a CSV file to be read.format
- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.header
- Column names to use for the resultant table.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
readHeaderlessCsv
@ScriptApi public static Table readHeaderlessCsv(File file, String format, StatusCallback progress, @Nullable Collection<String> header) throws IOExceptionReturns a memory table created from importing CSV data. Column data types are inferred from the data.- Parameters:
file
- a file object providing access to the CSV file to be read.format
- an Apache Commons CSV format name to be used to parse the CSV, or a single non-newline character to use as a delimiter.progress
- a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.header
- Column names to use for the resultant table, or null if column names should be automatically generated.- Returns:
- a Deephaven Table object
- Throws:
IOException
- if the file cannot be read
-
writeCsv
@ScriptApi public static void writeCsv(String sourcePath, String destPath, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sourcePath
- path to the table files to be exporteddestPath
- path to the CSV file to be writtencolumns
- a list of columns to include in the export- Throws:
IOException
- if source files cannot be read or target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(String sourcePath, String destPath, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sourcePath
- path to the table files to be exporteddestPath
- path to the CSV file to be writtencolumns
- a list of columns to include in the export- Throws:
IOException
- if source files cannot be read or target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(String sourcePath, String destPath, DBTimeZone timeZone, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sourcePath
- path to the table files to be exporteddestPath
- path to the CSV file to be writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- a list of columns to include in the export- Throws:
IOException
- if source files cannot be read or target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(String sourcePath, String destPath, DBTimeZone timeZone, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sourcePath
- path to the table files to be exporteddestPath
- path to the CSV file to be writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustednullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if source files cannot be read or target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, boolean compressed, String destPath, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to compress (bz2) the file being writtencolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, boolean compressed, String destPath, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to compress (bz2) the file being writtennullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtennullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, PrintStream out, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exportedout
- the stream to write tocolumns
- a list of columns to include in the export- Throws:
IOException
- if there is a problem writing to the stream
-
writeCsv
@ScriptApi public static void writeCsv(Table source, PrintStream out, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exportedout
- the stream to write tonullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if there is a problem writing to the stream
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to zip the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedcolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to zip the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustednullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table source, String destPath, boolean compressed, DBTimeZone timeZone, boolean nullsAsEmpty, char separator, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
source
- a Deephaven table object to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to zip the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustednullsAsEmpty
- if nulls should be written as blank instead of '(null)'separator
- the delimiter for the CSVcolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sources
- an array of Deephaven table objects to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to compress (bz2) the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedtableSeparator
- a String (normally a single character) to be used as the table delimitercolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sources
- an array of Deephaven table objects to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to compress (bz2) the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedtableSeparator
- a String (normally a single character) to be used as the table delimitercolumns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
writeCsv
@ScriptApi public static void writeCsv(Table[] sources, String destPath, boolean compressed, DBTimeZone timeZone, String tableSeparator, char fieldSeparator, boolean nullsAsEmpty, String... columns) throws IOExceptionWrites a DB table out as a CSV.- Parameters:
sources
- an array of Deephaven table objects to be exporteddestPath
- path to the CSV file to be writtencompressed
- whether to compress (bz2) the file being writtentimeZone
- a DBTimeZone constant relative to which DBDateTime data should be adjustedtableSeparator
- a String (normally a single character) to be used as the table delimiterfieldSeparator
- the delimiter for the CSV filesnullsAsEmpty
- if nulls should be written as blank instead of '(null)'columns
- a list of columns to include in the export- Throws:
IOException
- if the target file cannot be written
-
colSource
Creates an in-memory column of the specified type for a collection of values.- Type Parameters:
T
- the type to use for the new column- Parameters:
clazz
- the class to use for the new columnvalues
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
objColSource
Creates an in-memory column of the specified type for a collection of values- Type Parameters:
T
- the type to use for the new column- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type long for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type int for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type short for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type byte for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type char for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type double for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
colSource
Creates an in-memory column of type float for a collection of values.- Parameters:
values
- a collection of values to populate the new column- Returns:
- a Deephaven ColumnSource object
-
getKey
Returns a SmartKey for the specified row from a set of ColumnSources.- Parameters:
groupByColumnSources
- a set of ColumnSources from which to retrieve the datarow
- the row number for which to retrieve data- Returns:
- a Deephaven SmartKey object
-
getPrevKey
Returns a SmartKey for the row previous to the specified row from a set of ColumnSources.- Parameters:
groupByColumnSources
- a set of ColumnSources from which to retrieve the datarow
- the row number for which to retrieve the previous row's data- Returns:
- a Deephaven SmartKey object
-
col
Returns a ColumnHolder that can be used when creating in-memory tables.- Type Parameters:
T
- the type of the column- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
stringCol
Returns a ColumnHolder of type String that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
longCol
Returns a ColumnHolder of type long that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
intCol
Returns a ColumnHolder of type int that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
shortCol
Returns a ColumnHolder of type short that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
byteCol
Returns a ColumnHolder of type byte that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
charCol
Returns a ColumnHolder of type char that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
doubleCol
Returns a ColumnHolder of type double that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
floatCol
Returns a ColumnHolder of type float that can be used when creating in-memory tables.- Parameters:
name
- name of the columndata
- a list of values for the column- Returns:
- a Deephaven ColumnHolder object
-
emptyTable
Returns a new, empty Deephaven Table.- Parameters:
size
- the number of rows to allocate space for- Returns:
- a Deephaven Table with no columns.
-
emptyTable
Returns a new, empty Deephaven Table.- Parameters:
size
- the number of rows to allocate space fortableDefinition
- the TableDefinition (column names and properties) to use for the new table- Returns:
- a Deephaven Table with columns.
-
newTable
public static DynamicTable newTable(long size, List<String> names, List<ColumnSource> columnSources)Creates a new DynamicTable.- Parameters:
size
- the number of rows to allocatenames
- a List of column namescolumnSources
- a List of the ColumnSource(s)- Returns:
- a Deephaven DynamicTable
-
newTable
Creates a new DynamicTable.- Parameters:
size
- the number of rows to allocatecolumns
- a Map of column names and ColumnSources- Returns:
- a Deephaven DynamicTable
-
newTable
Creates a new DynamicTable.- Parameters:
definition
- the TableDefinition (column names and properties) to use for the new table- Returns:
- an empty Deephaven DynamicTable object
-
newTable
Creates a new DynamicTable.- Parameters:
columnHolders
- a list of ColumnHolders from which to create the table- Returns:
- a Deephaven DynamicTable
-
newTable
Creates a new DynamicTable.- Parameters:
columnHolders
- a list of ColumnHolders from which to create the table- Returns:
- a Deephaven DynamicTable
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
period
- time interval between new row additions.- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
period
- time interval between new row additionsreplayer
- data replayer- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiod
- time interval between new row additions- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiod
- time interval between new row additionsreplayer
- data replayer- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiod
- time interval between new row additions- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiod
- time interval between new row additionsreplayer
- data replayer- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
periodNanos
- time interval between new row additions in nanoseconds.- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
periodNanos
- time interval between new row additions in nanoseconds.replayer
- data replayer- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiodNanos
- time interval between new row additions in nanoseconds.- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiodNanos
- time interval between new row additions in nanoseconds.replayer
- data replayer- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiodNanos
- time interval between new row additions in nanoseconds.- Returns:
- time table
-
timeTable
Creates a table that adds a new row on a regular interval.- Parameters:
startTime
- start time for adding new rowsperiodNanos
- time interval between new row additions in nanoseconds.replayer
- data replayer- Returns:
- time table
-
merge
Concatenates multiple Deephaven Tables into a single Table.The resultant table will have rows from the same table together, in the order they are specified as inputs.
When ticking tables grow, they may run out of the 'pre-allocated' space for newly added rows. When more key- space is needed, tables in higher key-space are shifted to yet higher key-space to make room for new rows. Shifts are handled efficiently, but some downstream operations generate a linear O(n) amount of work per shifted row. When possible, one should favor ordering the constituent tables first by static/non-ticking sources followed by tables that are expected to grow at slower rates, and finally by tables that grow without bound.
- Parameters:
theList
- a List of Tables to be concatenated- Returns:
- a Deephaven table object
-
merge
Concatenates multiple Deephaven Tables into a single Table.The resultant table will have rows from the same table together, in the order they are specified as inputs.
When ticking tables grow, they may run out of the 'pre-allocated' space for newly added rows. When more key- space is needed, tables in higher key-space are shifted to yet higher key-space to make room for new rows. Shifts are handled efficiently, but some downstream operations generate a linear O(n) amount of work per shifted row. When possible, one should favor ordering the constituent tables first by static/non-ticking sources followed by tables that are expected to grow at slower rates, and finally by tables that grow without bound.
- Parameters:
tables
- a Collection of Tables to be concatenated- Returns:
- a Deephaven table object
-
merge
Concatenates multiple Deephaven Tables into a single Table.The resultant table will have rows from the same table together, in the order they are specified as inputs.
When ticking tables grow, they may run out of the 'pre-allocated' space for newly added rows. When more key- space is needed, tables in higher key-space are shifted to yet higher key-space to make room for new rows. Shifts are handled efficiently, but some downstream operations generate a linear O(n) amount of work per shifted row. When possible, one should favor ordering the constituent tables first by static/non-ticking sources followed by tables that are expected to grow at slower rates, and finally by tables that grow without bound.
- Parameters:
tables
- a list of Tables to be concatenated- Returns:
- a Deephaven table object
-
mergeSorted
Concatenates multiple sorted Deephaven Tables into a single Table sorted by the specified key column.The input tables must each individually be sorted by keyColumn, otherwise results are undefined.
- Parameters:
tables
- sorted Tables to be concatenatedkeyColumn
- the column to use when sorting the concatenated results- Returns:
- a Deephaven table object
-
mergeSorted
Concatenates multiple sorted Deephaven Tables into a single Table sorted by the specified key column.The input tables must each individually be sorted by keyColumn, otherwise results are undefined.
- Parameters:
tables
- a Collection of sorted Tables to be concatenatedkeyColumn
- the column to use when sorting the concatenated results- Returns:
- a Deephaven table object
-
roundDecimalColumns
Produce a new table with all the columns of this table, in the same order, but withdouble
andfloat
columns rounded tolong
s.- Returns:
- The new
Table
, with alldouble
andfloat
columns rounded tolong
s.
-
roundDecimalColumnsExcept
Produce a new table with all the columns of this table, in the same order, but with alldouble
andfloat
columns rounded tolong
s, except for the specifiedcolumnsNotToRound
.- Parameters:
columnsNotToRound
- The names of thedouble
andfloat
columns not to round tolong
s- Returns:
- The new
Table
, with columns modified as explained above
-
roundDecimalColumns
Produce a new table with all the columns of this table, in the same order, but withdouble
andfloat
columns rounded tolong
s.- Parameters:
columns
- The names of thedouble
andfloat
columns to round.- Returns:
- The new
Table
, with the specified columns rounded tolong
s. - Throws:
IllegalArgumentException
- Ifcolumns
is null, or if one of the specifiedcolumns
is neither adouble
column nor afloat
column.
-
computeFingerprint
Compute the SHA256 hash of the input table.
The hash is computed using every value in each row, using toString for unrecognized objects. The hash also includes the input table definition column names and types.
- Parameters:
source
- The table to fingerprint- Returns:
- The SHA256 hash of the table data and
TableDefinition
- Throws:
IOException
- If an error occurs during the hashing.
-
base64Fingerprint
Compute the SHA256 hash of the input table and return it in base64 string format.
- Parameters:
source
- The table to fingerprint- Returns:
- The SHA256 hash of the table data and
TableDefinition
- Throws:
IOException
- If an error occurs during the hashing.
-