Interface TableMap

All Superinterfaces:
Deflatable<TableMap>, LivenessManager, LivenessNode, LivenessReferent, TransformableTableMap
All Known Implementing Classes:
FilteredTableMap, LastByTableImportState.ResultTableMap, LocalTableMap, TableMapClient, TableMapImpl, TableMapSupplier

public interface TableMap extends Deflatable<TableMap>, TransformableTableMap, LivenessNode
A map of tables.
  • Field Details

  • Method Details

    • emptyMap

      static TableMap emptyMap()
      Returns an instance of the EmptyTableMap.
    • isSentinel

      static boolean isSentinel(Object key)
      Check the key passed to the function in transformTablesWithKey(BiFunction), to see if it's the sentinel.
      Parameters:
      key - the object
      Returns:
      true if the key is the sentinel
    • get

      Table get(Object key)
      Gets a table with a given key. Note that this causes the current LivenessManager (see LivenessScopeStack) to manage the result if non-null.
      Parameters:
      key - key
      Returns:
      table associated with the key, or null if the key is not present.
    • getWithTransform

      Table getWithTransform(Object key, Function<Table,Table> transform)
      Gets a table with a given key, applying the specified transform before returning.
      Parameters:
      key - key
      Returns:
      table associated with the key, or null if the key is not present.
    • getKeySet

      Object[] getKeySet()
      Gets the keys.
      Returns:
      keys
    • entrySet

      Gets the entries.
      Returns:
      the entries
    • values

      Collection<Table> values()
      Gets the values.
      Returns:
      values
    • size

      int size()
      Number of tables in the map.
      Returns:
      number of tables in the map.
    • populateKeys

      TableMap populateKeys(Object... keys)
      When creating the table map, some of the keys that we would like to be there eventually may not exist. This call lets you pre-populate keys, so that at initialization time you can perform the appropriate joins, etc., on empty tables that you expect to be populated in the future.
      Parameters:
      keys - the keys to add to the map
      Returns:
      this TableMap
    • addListener

      void addListener(TableMap.Listener listener)
      Add a new listener for changes to the map.
      Parameters:
      listener - map change listener
    • removeListener

      void removeListener(TableMap.Listener listener)
      Removes a map change listener.
      Parameters:
      listener - map change listener.
    • addKeyListener

      void addKeyListener(TableMap.KeyListener listener)
      Listen to changes in the map's keys.
      Parameters:
      listener - key change listener
    • removeKeyListener

      void removeKeyListener(TableMap.KeyListener listener)
      Removes a key change listener.
      Parameters:
      listener - key change listener to remove
    • flatten

      TableMap flatten()
      Flattens all of the result tables within the tablemap.
    • preemptiveUpdatesTable

      TableMap preemptiveUpdatesTable(int intervalMillis)
      Creates preemptive tables out of all of the result tables within the tablemap.
      Parameters:
      intervalMillis - update interval for the preemptive tables
    • apply

      <R> R apply(com.fishlib.base.Function.Unary<R,TableMap> function)
      Applies a function to this tableMap. This is useful if you have a reference to a tableMap; but not the database and want to run a series of operations against the table map without each individual operation resulting in a remote method invocation.
      Type Parameters:
      R - the return type of function
      Parameters:
      function - the function to run, its single argument will be this table map.
      Returns:
      the return value of function
    • transformTables

      default TableMap transformTables(Function<Table,Table> function)
      Applies a transformation function on all tables in the TableMap, producing a new TableMap which will update as new keys are added.
      Parameters:
      function - the function to apply to each table in this TableMap
      Returns:
      a new TableMap where each table has had function applied
    • transformTables

      default TableMap transformTables(TableDefinition returnDefinition, Function<Table,Table> function)
      Applies a transformation function on all tables in the TableMap, producing a new TableMap which will update as new keys are added.
      Parameters:
      returnDefinition - the table definition for the tables the function will return
      function - the function to apply to each table in this TableMap
      Returns:
      a new TableMap where each table has had function applied
    • transformTablesWithKey

      TableMap transformTablesWithKey(BiFunction<Object,Table,Table> function)
      Applies a transformation function on all tables in the TableMap, producing a new TableMap which will update as new keys are added.

      The function may be passed a sentinel key, which can be checked with isSentinel(Object). On the sentinel key, the function will be passed in an empty table, and is expected to return an empty table of the proper definition. To avoid this sentinel invocation, callers can be explicit and use transformTablesWithKey(TableDefinition, BiFunction).

      Parameters:
      function - the bifunction to apply to each table in this TableMap
      Returns:
      a new TableMap where each table has had function applied
    • transformTablesWithKey

      TableMap transformTablesWithKey(TableDefinition returnDefinition, BiFunction<Object,Table,Table> function)
      Applies a transformation function on all tables in the TableMap, producing a new TableMap which will update as new keys are added.
      Parameters:
      returnDefinition - the table definition for the tables the function will return
      function - the bifunction to apply to each table in this TableMap
      Returns:
      a new TableMap where each table has had function applied
    • transformTablesWithMap

      TableMap transformTablesWithMap(TableMap otherMap, BiFunction<Table,Table,Table> function)
      Applies a BiFunction function on all tables in this TableMap and otherMap that have matching keys, producing a new TableMap which will update as new keys are added. Only applies the function to tables which exist in both maps.
      Parameters:
      otherMap - the other TableMap
      function - the function to apply to each table in this TableMap, the tables in this map are the first argument the tables in the other map are the second argument.
      Returns:
      a new TableMap where each table has had function applied
    • asTableMap

      default TableMap asTableMap()
      Description copied from interface: TransformableTableMap
      If you're a TableMap return this, otherwise if you're a Proxy return the underlying TableMap.
      Specified by:
      asTableMap in interface TransformableTableMap
      Returns:
      a TableMap representation of this object
    • deflate

      default Inflatable<TableMap> deflate(@NotNull ExportedObjectClient client)
      Description copied from interface: Deflatable
      Convert this object into an Inflatable suitable for serialization.
      Specified by:
      deflate in interface Deflatable<TableMap>
      Parameters:
      client - the ExportedObjectClient we are deflating for.
      Returns:
      an Inflatable for serializing to the client