Class LocalTableWriter

java.lang.Object
com.illumon.iris.db.tables.appendable.local.LocalTableWriter
All Implemented Interfaces:
Entry, Record, Row, TableWriter, BufferedAppendable
Direct Known Subclasses:
DiskTableWriter

public class LocalTableWriter extends Object implements TableWriter, BufferedAppendable
TableWriter for concurrently-readable table writing to a local table location.
  • Constructor Details

    • LocalTableWriter

      public LocalTableWriter(@NotNull LocalAppendableTable table)
      Construct a writer for the supplied table.
      Parameters:
      table - The table to write to
    • LocalTableWriter

      public LocalTableWriter(@NotNull LocalAppendableTable table, boolean needRowSupport)
      Construct a writer for the supplied table.
      Parameters:
      table - The table to write to
      needRowSupport - Should this local table writer allocate a Row for traditional row-by-row ingest
  • Method Details

    • 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.
    • 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.
    • 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.
    • 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
    • getSetter

      public RowSetter getSetter(@NotNull String columnName)
      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:
      columnName - column name
      Returns:
      setter for the column.
    • getColumn

      public <CT extends LocalAppendableColumn<?>> CT getColumn(@NotNull String name, @NotNull Class<CT> clazz)
      Get a LocalAppendableColumn for use by writing code that doesn't use RowSetters.
      Parameters:
      name - The column name
      clazz - The expected column class
      Returns:
      The column
    • setFlags

      public void setFlags(@NotNull 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
    • inTransaction

      public final boolean inTransaction()
      Check whether a transaction is in progress.
      Returns:
      Whether a transaction is in progress
    • inInvalidTransaction

      public final boolean inInvalidTransaction()
      Check whether an invalid transaction (which will never succeed) is in progress.
      Returns:
      Whether an invalid transaction is in progress
    • startTransaction

      public final void startTransaction()
      Begin a transaction. It is an error to call this method if a transaction is already in progress.
    • maybeStartTransaction

      public void maybeStartTransaction()
      If we're not currently in a transaction, begin one.
    • startInvalidTransaction

      public final void startInvalidTransaction()
      Begin a transaction that is guaranteed to never succeed. It is an error to call this method if a transaction is already in progress.
    • abortTransaction

      public final void abortTransaction()
      Abort a transaction. It is an error to call this method if a transaction is not in progress.
    • maybeAbortTransaction

      public final void maybeAbortTransaction()
      Abort a transaction if one is in progress.
    • endTransaction

      public final void endTransaction()
      End a transaction. It is an error to call this method if a transaction is not in progress or the current transaction is invalid.
    • maybeEndTransaction

      public final void maybeEndTransaction()
      End a transaction if one is in progress.
    • adviseRowsWritten

      public final void adviseRowsWritten(long count)
      Update accounting for rows were written.
      Parameters:
      count - The number of rows that were written
    • writeRow

      public final void writeRow() throws IOException
      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
      Throws:
      IOException - problem writing the row
    • dirty

      public boolean dirty()
      Test if there is data to flush.
      Returns:
      Whether there is data to flush
    • flush

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

      public void prepareCheckpoint()
      Description copied from interface: BufferedAppendable
      Optional operation. Prepare a checkpoint snapshot for the next call to BufferedAppendable.force(). Should be called directly after BufferedAppendable.flush(), with no intervening modification operations.
      Specified by:
      prepareCheckpoint in interface BufferedAppendable
    • force

      public void force()
      Description copied from interface: BufferedAppendable
      Force all flushed data to be persisted to permanent storage. Will consistently and atomically persist the last prepared checkpoint in implementations that implement BufferedAppendable.prepareCheckpoint(). Does not imply BufferedAppendable.flush(), as this is a distinct operation in all implementations. May be called concurrently by threads other than the "writing thread".
      Specified by:
      force in interface BufferedAppendable
    • maybeForce

      public boolean maybeForce()
      Description copied from interface: BufferedAppendable
      Perform a BufferedAppendable.force() if there is data pending persistence. Implementations that don't keep track of pending data explicitly will always invoke BufferedAppendable.force() pessimistically.
      Specified by:
      maybeForce in interface BufferedAppendable
      Returns:
      Whether this call may have done any actual work (i.e. there was data pending or assumed to be pending)
    • close

      public void close()
      Description copied from interface: TableWriter
      Closes the writer.
      Specified by:
      close in interface BufferedAppendable
      Specified by:
      close in interface TableWriter
    • release

      public void release()
      Description copied from interface: BufferedAppendable
      Release any resources held. Called after an error in preparation for termination. For external callers, this should be done as the final access to this column with the exception of any asynchronous BufferedAppendable.force() operations.
      Specified by:
      release in interface BufferedAppendable
    • updateImportState

      public void updateImportState(@NotNull UnaryOperator<ImportState> updater)
      Set the import state object (as in setImportState(ImportState)) after applying the supplied updater function to the existing import state object.
      Parameters:
      updater - The import state updater
    • setImportState

      public void setImportState(ImportState importState)
      Set an import state object to be part of checkpoints for the output table.
      Parameters:
      importState - The import state
    • setImportDetails

      public void setImportDetails(Properties importDetails)
      Set a trivial import state object wrapping the supplied import details to be part of checkpoints for the output table.
      Parameters:
      importDetails - The import details