Class DynamicTableWriter

java.lang.Object
io.deephaven.engine.table.impl.util.DynamicTableWriter
All Implemented Interfaces:
Row, TableWriter

public class DynamicTableWriter
extends Object
implements 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.

  • Constructor Details

    • DynamicTableWriter

      public DynamicTableWriter​(TableHeader header, Map<String,​Object> constantValues)
      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

      public DynamicTableWriter​(TableHeader header)
      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

      public DynamicTableWriter​(String[] columnNames, Type<?>[] columnTypes)
      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

      public DynamicTableWriter​(@NotNull TableDefinition definition)
      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

      public DynamicTableWriter​(TableDefinition definition, Map<String,​Object> constantValues)
      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

      public UpdateSourceQueryTable getTable()
      Gets the table created by this DynamicTableWriter.

      The returned table is registered with the UpdateGraphProcessor, and new rows become visible within the run loop.

      Returns:
      a live table with the output of this log
    • getRowWriter

      public Row 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 call DynamicTableWriter.addRowToTableIndex before advancing to the next row.

      Specified by:
      getRowWriter in interface TableWriter
      Returns:
      a Row from which you can retrieve setters and call write row.
    • getSetter

      public DynamicTableWriter.PermissiveRowSetter getSetter​(String name)
      Returns a RowSetter for the given column. If required, a Row object is allocated. You can not mix calls with getSetter and getRowWriter. After setting each column, you must call addRowToTableIndex, before beginning to write the next row.
      Specified by:
      getSetter in interface Row
      Specified by:
      getSetter in interface TableWriter
      Parameters:
      name - column name.
      Returns:
      a RowSetter for the given column
    • setFlags

      public void setFlags​(Row.Flags flags)
      Description copied from interface: TableWriter

      The implementation is likely to delegate to Row.setFlags(Flags) in a default Row instance.

      Specified by:
      setFlags in interface Row
      Specified by:
      setFlags in interface TableWriter
    • writeRow

      public void writeRow()
      Writes the current row created with the getSetter call, and advances the current row by one.

      The row will be made visible in the table after the UpdateGraphProcessor run cycle completes.

      Specified by:
      writeRow in interface Row
      Specified by:
      writeRow in interface TableWriter
    • logRow

      public void logRow​(Map<String,​Object> values)
      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

      public void logRow​(Object... values)
      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

      public 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. 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

      public void logRowPermissive​(Object... values)
      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 interface TableWriter
    • size

      public long size()
      Description copied from interface: Row
      Number of rows written out.
      Specified by:
      size in interface Row
      Returns:
      number of rows written out.
    • close

      public void close() throws IOException
      Description copied from interface: TableWriter
      Closes the writer.
      Specified by:
      close in interface TableWriter
      Throws:
      IOException - problem closing the writer.
    • getColumnTypes

      public Class[] getColumnTypes()
      Description copied from interface: TableWriter
      Gets the column types for the table.
      Specified by:
      getColumnTypes in interface TableWriter
      Returns:
      column types for the table.
    • getColumnNames

      public String[] getColumnNames()
      Description copied from interface: TableWriter
      Gets the column names for the table.
      Specified by:
      getColumnNames in interface TableWriter
      Returns:
      column names for the table.