Class ArrayBackedTableWriter

java.lang.Object
com.illumon.iris.db.v2.utils.ArrayBackedTableWriter
All Implemented Interfaces:
Entry, Record, Row, TableWriter
Direct Known Subclasses:
RowOrientedArrayBackedTableWriter

public class ArrayBackedTableWriter
extends Object
implements TableWriter
The ArrayBackedTableWriter creates an in-memory table using ArrayBackedColumnSources of the type specified in the constructor. You can retrieve the table using the getTable function. It is designed to work with generated loggers, and won't work with other row-oriented implementations. It is recommended that startNewTable be called with an appropriate table size before logging through this TableWriter. This class is not thread safe, you must synchronize externally.
  • Field Details

  • Constructor Details

    • ArrayBackedTableWriter

      public ArrayBackedTableWriter​(String[] columnNames, Class<?>[] columnTypes)
      Create 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)
    • ArrayBackedTableWriter

      public ArrayBackedTableWriter​(TableDefinition definition)
      Create a TableWriter that produces an in-memory table using the provided TableDefinition
      Parameters:
      definition - the Table definition
  • Method Details

    • setNextRowIndex

      public void setNextRowIndex​(int rowIndex)
      Sets the index where the next row will be written. This allows the caller to overwrite previously written rows. Note that once it is called, it is up to the caller to manage the row index as the Table Writer no longer knows what will be the last row.
      Parameters:
      rowIndex - the row index to write
    • setUpdateIndex

      public void setUpdateIndex​(boolean updateIndex)
      Sets whether or not the writer should update the index (defaults to true). Set this to false to update the index manually.
      Parameters:
      updateIndex - whether or not to update the index
    • startNewTable

      public void startNewTable​(int expectedSize)
      Create a new table to be used for subsequent logging operations
      Parameters:
      expectedSize - the expected maximum size of the table
    • startNewTable

      public void startNewTable​(int expectedSize, BiFunction<Index,​Map<String,​ColumnSource>,​QueryTable> createTableFunction)
      Create a new table to be used for subsequent logging operations
      Parameters:
      expectedSize - the expected maximum size of the table
      createTableFunction - a function that creates a query table
    • getQueryTable

      public QueryTable getQueryTable()
      Return the current Table being written to by this ArrayBackedTableWriter
      Returns:
      the underlying Table
    • supportAllTypes

      public boolean supportAllTypes()
      Description copied from interface: TableWriter
      True if all data types can be written out; false otherwise.
      Specified by:
      supportAllTypes in interface TableWriter
      Returns:
      true if all data types can be written out; false otherwise.
    • 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.
    • 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()
      Description copied from interface: TableWriter
      Writes out a new row (values set using setters).

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

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

      public void flush()
      Description copied from interface: TableWriter
      Flushes data out.
      Specified by:
      flush in interface TableWriter
    • getSetter

      public RowSetter getSetter​(String name)
      Description copied from interface: TableWriter
      Gets a setter for a column.

      The implementation is likely to delegate to Row.getSetter(String) in a default Row instance.

      Specified by:
      getSetter in interface Row
      Specified by:
      getSetter in interface TableWriter
      Parameters:
      name - column name
      Returns:
      setter for the column.
    • getRowWriter

      public Row getRowWriter()
      Description copied from interface: TableWriter
      Get a writer for a Row entries. This is likely to be newly created, so callers should cache this value. In practice, TableWriter implementations generally cache the result of the first call to this method as a primary writer.
      Specified by:
      getRowWriter in interface TableWriter
      Returns:
      a Row, likely newly created