Class LastByTableImportState<KEY_TYPE>

java.lang.Object
com.illumon.iris.db.tables.dataimport.importstate.TupleKeyedAbstractImportState<KEY_TYPE>
com.illumon.iris.db.tables.dataimport.importstate.lastby.LastByTableImportState<KEY_TYPE>
All Implemented Interfaces:
ImportState, LiveTable, Externalizable, Serializable, Runnable

public class LastByTableImportState<KEY_TYPE> extends TupleKeyedAbstractImportState<KEY_TYPE> implements LiveTable, Externalizable

ImportState that publishes a last-by view of the data being imported, producing a table intended for concurrent usage by clients with access to the importing process.

See Also:
  • Constructor Details

    • LastByTableImportState

      public LastByTableImportState()
      Constructor for an empty import state with null name.
    • LastByTableImportState

      public LastByTableImportState(String name)
      Constructor for an empty import state.
      Parameters:
      name - The name for this last-by view (see getTableMap(TableKey, String)).
  • Method Details

    • getTableMap

      public static LastByTableImportState.ResultTableMap getTableMap(@NotNull TableKey tableKey)
      Get a LocalTableMap keyed by TableLocationKey of DynamicTables that contain only an Index and no user-facing ColumnSources. The contents of the result are produced by LastByImportState instances for the supplied TableKey and null name
      Parameters:
      tableKey - The key
      Returns:
      The table map, possibly empty
    • getTableMap

      public static LastByTableImportState.ResultTableMap getTableMap(@NotNull TableKey tableKey, String name)
      Get a LocalTableMap keyed by TableLocationKey of DynamicTables that contain only an Index and no user-facing ColumnSources. The contents of the result are produced by LastByTableImportState instances for the supplied TableKey and name. Distinct names should be used for distinct last-by import state views of the same table. TODO: Consider whether we should implement a LocalTableMap equivalent that stores weakly-reachable values.
      Parameters:
      tableKey - The key
      name - The name
      Returns:
      The table map, possibly empty
    • writeExternal

      public void writeExternal(@NotNull ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(@NotNull ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • newRowForKey

      public final void newRowForKey(KEY_TYPE key)

      Observe a new row for the specified key, which may be compound.

      It is required that users of this method render their key immutable.

      The recommended way to do so is to invoke TupleKeyedAbstractImportState.prepareElement(Object) on single element keys, or construct a CanonicalizableTuple directly from primitive elements and the result of TupleKeyedAbstractImportState.prepareElement(Object) on all Object elements of a compound key. Alternatively, TupleKeyedAbstractImportState.prepareKey(Object) tries to do the correct thing, but may not be as performant. Users must not use SmartKey or Pair directly as keys or indirectly as elements.

      Specified by:
      newRowForKey in class TupleKeyedAbstractImportState<KEY_TYPE>
      Parameters:
      key - The key
    • skipRow

      public final void skipRow()
      Observe the passing of a row that will not be a part of the last-by view.
    • getImportDetails

      @NotNull public Properties getImportDetails()
      Specified by:
      getImportDetails in interface ImportState
    • ensureInitialized

      public void ensureInitialized(@NotNull FullTableLocationKey locationKey)
      Description copied from interface: ImportState
      Called when non-import code needs to ensure that an ImportState's internals have been initialized because of their side effects. Must not interfere with concurrent data ingestion in the same process. Generally should be treated as a query operation, and the caller should hold the LiveTableMonitor lock.
      Specified by:
      ensureInitialized in interface ImportState
      Parameters:
      locationKey - The full table location key of the location whose ImportState is being initialized
    • onResume

      public void onResume(@NotNull FullTableLocationKey locationKey)
      Description copied from interface: ImportState
      Called when data ingestion is resumed for the location observed by this ImportState.
      Specified by:
      onResume in interface ImportState
      Parameters:
      locationKey - The full table location key of the location that has been resumed
    • onTruncate

      public void onTruncate(@NotNull FullTableLocationKey locationKey)
      Description copied from interface: ImportState
      Called when the underlying table location has been truncated. Useful for resetting any in-memory state that may otherwise linger inappropriately.
      Specified by:
      onTruncate in interface ImportState
      Parameters:
      locationKey - The full table location key of the location that has been truncated
    • onFlush

      public void onFlush()
      Description copied from interface: ImportState
      Called when the data ingestion process for the location observed by this ImportState is flushed (properly, after it has been flushed and when the resulting size has been made visible if applicable).
      Specified by:
      onFlush in interface ImportState
    • onRelease

      public void onRelease()
      Description copied from interface: ImportState
      Call when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in an inconsistent state.
      Specified by:
      onRelease in interface ImportState
    • onClose

      public void onClose()
      Description copied from interface: ImportState
      Called when the data ingestion process for the location observed by this ImportState is finished, temporarily or permanently, in a consistent state.
      Specified by:
      onClose in interface ImportState
    • refresh

      public void refresh()
      Description copied from interface: LiveTable
      Refresh this LiveTable.
      Specified by:
      refresh in interface LiveTable