Class PrintListener

All Implemented Interfaces:
LogOutputAppendable, LivenessManager, LivenessNode, LivenessReferent, TableListener, TableUpdateListener, NotificationQueue.Dependency, Serializable

@ScriptApi public class PrintListener extends InstrumentedTableUpdateListener
A simple listener that prints out each update received from a table.

This can be used to debug the performance of a query by attaching to various tables in an effort to understand the update pattern. Optionally, you can also print out the head of the table.

Output is directed to stdout, thus this should not be enabled in production queries.

After you are finished, call the stop() method to remove this listener from the source table.

See Also:
  • Constructor Details

    • PrintListener

      @ScriptApi public PrintListener(String description, Table table)
      Create a PrintListener attached to the given table.
      Parameters:
      description - the description (for use in each print statement)
      table - the table to attach to
    • PrintListener

      @ScriptApi public PrintListener(String description, Table table, int rowCount)
      Create a PrintListener attached to the given table.
      Parameters:
      description - the description (for use in each print statement)
      table - the table to attach to
      rowCount - how many rows to print out on each update
  • Method Details

    • onUpdate

      public void onUpdate(TableUpdate upstream)
      Description copied from interface: TableUpdateListener
      Process notification of table changes.

      The TableUpdateListener onUpdate call executes within the UpdateGraph refresh loop. Any tables used within the listener's onUpdate call must have already been refreshed. Using the typical pattern of a Listener that is listening to a single table, with Table.addUpdateListener(TableUpdateListener), this is trivially true.

      When the listener must reference more than just one parent, the tables (or other objects) it references, must be made a NotificationQueue.Dependency of the listener. For listeners that reference multiple ticking tables, a common pattern is to use a MergedListener and collection of ListenerRecorders.

      Parameters:
      upstream - The set of upstream table updates.
    • onFailureInternal

      public void onFailureInternal(Throwable originalException, TableListener.Entry sourceEntry)
      Specified by:
      onFailureInternal in class InstrumentedTableListenerBase
    • stop

      public void stop()
      Remove this listener from the table.