Class DynamicTableWriter
java.lang.Object
io.deephaven.engine.table.impl.util.DynamicTableWriter
- All Implemented Interfaces:
Row
,TableWriter
The DynamicTableWriter creates an in-memory table using ArrayBackedColumnSources of the type specified in the
constructor. You can retrieve the table using the
getTable
function.
This class is not thread safe, you must synchronize externally. However, multiple setters may safely log concurrently.
- ImplNote:
- The constructor publishes
this
to theUpdateGraph
and thus cannot be subclassed.
-
Nested Class Summary
-
Field Summary
Fields inherited from interface io.deephaven.tablelogger.TableWriter
NULL_SETTER
-
Constructor Summary
ConstructorDescriptionDynamicTableWriter
(@NotNull TableDefinition definition) Creates a write object that would write an object at a given locationDynamicTableWriter
(TableDefinition definition, Map<String, Object> constantValues) Creates a write object that would write an object at a given locationDynamicTableWriter
(TableHeader header) Creates a TableWriter that produces an in-memory table using the provided column names and types.DynamicTableWriter
(TableHeader header, Map<String, Object> constantValues) Creates a TableWriter that produces an in-memory table using the provided column names and types.DynamicTableWriter
(String[] columnNames, Type<?>[] columnTypes) Creates a TableWriter that produces an in-memory table using the provided column names and types.Creates a TableWriter that produces an in-memory table using the provided column names and types. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the writer.void
flush()
Flushes data out.String[]
Gets the column names for the table.Class[]
Gets the column types for the table.Returns a row writer, which allocates the row.Returns a RowSetter for the given column.getTable()
Gets the table created by this DynamicTableWriter.void
This is a convenience function so that you can log an entire row at a time.void
This is a convenience function so that you can log an entire row at a time using a Map.void
logRowPermissive
(Object... values) This is a convenience function so that you can log an entire row at a time.void
logRowPermissive
(Map<String, Object> values) This is a convenience function so that you can log an entire row at a time using a Map.void
long
size()
Number of rows written out.void
writeRow()
Writes the current row created with thegetSetter
call, and advances the current row by one.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.deephaven.tablelogger.Row
getColumnPartitionValue, setColumnPartitionValue
Methods inherited from interface io.deephaven.tablelogger.TableWriter
getSetter
-
Constructor Details
-
DynamicTableWriter
Creates a TableWriter that produces an in-memory table using the provided column names and types.- Parameters:
header
- the names and types of the columns in the output table (and our input)constantValues
- a Map of columns with constant values
-
DynamicTableWriter
Creates a TableWriter that produces an in-memory table using the provided column names and types.- Parameters:
header
- the names and types of the columns in the output table (and our input)
-
DynamicTableWriter
public DynamicTableWriter(String[] columnNames, Type<?>[] columnTypes, Map<String, Object> constantValues) Creates a TableWriter that produces an in-memory table using the provided column names and types.- Parameters:
columnNames
- the names of the columns in the output table (and our input)columnTypes
- the types of the columns in the output table (must be compatible with the input)constantValues
- a Map of columns with constant values
-
DynamicTableWriter
Creates a TableWriter that produces an in-memory table using the provided column names and types.- Parameters:
columnNames
- the names of the columns in the output table (and our input)columnTypes
- the types of the columns in the output table (must be compatible with the input)
-
DynamicTableWriter
Creates a write object that would write an object at a given location- Parameters:
definition
- The table definition to create the dynamic table writer for
-
DynamicTableWriter
Creates a write object that would write an object at a given location- Parameters:
definition
- The table definition to create the dynamic table writer for
-
-
Method Details
-
getTable
Gets the table created by this DynamicTableWriter.The returned table is registered with the PeriodicUpdateGraph, and new rows become visible within the run loop.
- Returns:
- a live table with the output of this log
-
getRowWriter
Returns a row writer, which allocates the row. You may get setters for the row, and then call addRowToTableIndex when you are finished. Because the row is allocated when you call this function, it is possible to get several Row objects before calling addRowToTableIndex.This contrasts with
DynamicTableWriter.getSetter
, which allocates a single row; and you must callDynamicTableWriter.addRowToTableIndex
before advancing to the next row.- Specified by:
getRowWriter
in interfaceTableWriter
- Returns:
- a Row from which you can retrieve setters and call write row.
-
getSetter
Returns a RowSetter for the given column. If required, a Row object is allocated. You can not mix calls withgetSetter
andgetRowWriter
. After setting each column, you must calladdRowToTableIndex
, before beginning to write the next row.- Specified by:
getSetter
in interfaceRow
- Specified by:
getSetter
in interfaceTableWriter
- Parameters:
name
- column name.- Returns:
- a RowSetter for the given column
-
setFlags
Description copied from interface:TableWriter
The implementation is likely to delegate to
Row.setFlags(Flags)
in a default Row instance.- Specified by:
setFlags
in interfaceRow
- Specified by:
setFlags
in interfaceTableWriter
-
writeRow
public void writeRow()Writes the current row created with thegetSetter
call, and advances the current row by one.The row will be made visible in the table after the PeriodicUpdateGraph run cycle completes.
- Specified by:
writeRow
in interfaceRow
- Specified by:
writeRow
in interfaceTableWriter
-
logRow
This is a convenience function so that you can log an entire row at a time using a Map. You must specify all values in the setters map (and can't have any extras). The type of the value must be castable to the type of the setter.- Parameters:
values
- a map from column name to value for the row to be logged
-
logRow
This is a convenience function so that you can log an entire row at a time.- Parameters:
values
- an array containing values to be logged, in order of the fields specified by the constructor
-
logRowPermissive
This is a convenience function so that you can log an entire row at a time using a Map. You must specify all values in the setters map (and can't have any extras). The type of the value must be convertible (safely or unsafely) to the type of the permissive setter.- Parameters:
values
- a map from column name to value for the row to be logged
-
logRowPermissive
This is a convenience function so that you can log an entire row at a time. You must specify all values in the setters map (and can't have any extras). The type of the value must be convertible (safely or unsafely) to the type of the permissive setter.- Parameters:
values
- an array containing values to be logged, in order of the fields specified by the constructor
-
flush
public void flush()Description copied from interface:TableWriter
Flushes data out.- Specified by:
flush
in interfaceTableWriter
-
size
public long size()Description copied from interface:Row
Number of rows written out. -
close
Description copied from interface:TableWriter
Closes the writer.- Specified by:
close
in interfaceTableWriter
- Throws:
IOException
- problem closing the writer.
-
getColumnTypes
Description copied from interface:TableWriter
Gets the column types for the table.- Specified by:
getColumnTypes
in interfaceTableWriter
- Returns:
- column types for the table.
-
getColumnNames
Description copied from interface:TableWriter
Gets the column names for the table.- Specified by:
getColumnNames
in interfaceTableWriter
- Returns:
- column names for the table.
-