Class StreamToBlinkTableAdapter

java.lang.Object
io.deephaven.stream.StreamToBlinkTableAdapter
All Implemented Interfaces:
LogOutputAppendable, NotificationQueue.Dependency, StreamConsumer, StreamFailureConsumer, SafeCloseable, AutoCloseable, Runnable

public class StreamToBlinkTableAdapter extends Object implements StreamConsumer, Runnable, NotificationQueue.Dependency, SafeCloseable
Adapter for converting streams of data into columnar Deephaven tables that conform to blink table semantics.
ImplNote:
The constructor publishes this to an UpdateSourceRegistrar and thus cannot be subclassed.
  • Constructor Details

    • StreamToBlinkTableAdapter

      public StreamToBlinkTableAdapter(@NotNull @NotNull TableDefinition tableDefinition, @NotNull @NotNull StreamPublisher streamPublisher, @NotNull @NotNull UpdateSourceRegistrar updateSourceRegistrar, @NotNull @NotNull String name)
      Construct the adapter with initialize == true and without extra attributes.

      Equivalent to new StreamToBlinkTableAdapter(tableDefinition, streamPublisher, updateSourceRegistrar, name, Map.of(), true).

      Parameters:
      tableDefinition - the table definition
      streamPublisher - the stream publisher
      updateSourceRegistrar - the update source registrar
      name - the name
    • StreamToBlinkTableAdapter

      public StreamToBlinkTableAdapter(@NotNull @NotNull TableDefinition tableDefinition, @NotNull @NotNull StreamPublisher streamPublisher, @NotNull @NotNull UpdateSourceRegistrar updateSourceRegistrar, @NotNull @NotNull String name, @NotNull @NotNull Map<String,Object> extraAttributes)
      Construct the adapter with initialize == true.

      Equivalent to new StreamToBlinkTableAdapter(tableDefinition, streamPublisher, updateSourceRegistrar, name, extraAttributes, true).

      Parameters:
      tableDefinition - the table definition
      streamPublisher - the stream publisher
      updateSourceRegistrar - the update source registrar
      name - the name
      extraAttributes - the extra attributes to set on the resulting table
    • StreamToBlinkTableAdapter

      public StreamToBlinkTableAdapter(@NotNull @NotNull TableDefinition tableDefinition, @NotNull @NotNull StreamPublisher streamPublisher, @NotNull @NotNull UpdateSourceRegistrar updateSourceRegistrar, @NotNull @NotNull String name, @NotNull @NotNull Map<String,Object> extraAttributes, boolean initialize)
      Construct the adapter.
      Parameters:
      tableDefinition - the table definition
      streamPublisher - the stream publisher
      updateSourceRegistrar - the update source registrar
      name - the name
      extraAttributes - the extra attributes to set on the resulting table
      initialize - if the constructor should invoke initialize(); if false, the caller is responsible for invoking initialize().
  • Method Details

    • initialize

      public void initialize()
      Initialize this adapter by invoking StreamPublisher.register(StreamConsumer) and UpdateSourceRegistrar.addSource(Runnable) with this. Must be called once if and only if this was constructed with initialize == false.
      See Also:
    • table

      public Table table()
      Return the blink table that this adapter is producing, and ensure that this StreamToBlinkTableAdapter no longer enforces strong reachability of the result. May return null if invoked more than once and the initial caller does not enforce strong reachability of the result.
      Returns:
      The resulting blink table
    • isAlive

      public boolean isAlive()
      Checks whether this is alive; if false, the publisher should stop publishing new data and release any related resources as soon as practicable since publishing won't have any downstream effects.

      Once this is false, it will always remain false. For more prompt notifications, publishers may prefer to respond to StreamPublisher.shutdown().

      Returns:
      if this is alive
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • accept

      @SafeVarargs public final void accept(@NotNull @NotNull WritableChunk<Values>... data)
      Description copied from interface: StreamConsumer
      Accept a batch of rows splayed across per-column chunks of values.

      Ownership of data passes to the consumer, which must be sure to close each chunk when it's no longer needed.

      Implementations will generally have a mechanism for determining the expected number and type of input chunks, but this is not dictated at the interface level.

      Specified by:
      accept in interface StreamConsumer
      Parameters:
      data - Per-column chunks of values. Must all have the same size.
    • accept

      public final void accept(@NotNull @NotNull Collection<WritableChunk<Values>[]> data)
      Accept a collection of batches of rows splayed across per-column chunks of values.

      Ownership of all the chunks contained within data passes to the consumer, which must be sure to close each chunk when it's no longer needed.

      Implementations will generally have a mechanism for determining the expected number and type of input chunks for each element, but this is not dictated at the interface level.

      Implementations may provide more specific semantics about this method in comparison to repeated invocations of StreamConsumer.accept(WritableChunk[]).

      Ensures that the blink table sees the full collection of chunks in a single cycle.

      Specified by:
      accept in interface StreamConsumer
      Parameters:
      data - A collection of per-column chunks of values. All chunks in each element must have the same size, but different elements may have differing chunk sizes.
    • acceptFailure

      public void acceptFailure(@NotNull @NotNull Throwable cause)
      Description copied from interface: StreamFailureConsumer
      Report an error while processing the stream.
      Specified by:
      acceptFailure in interface StreamFailureConsumer
      Parameters:
      cause - the cause of the error
    • satisfied

      public boolean satisfied(long step)
      Description copied from interface: NotificationQueue.Dependency
      Is this ancestor satisfied? Note that this method must be safe to call on any thread.
      Specified by:
      satisfied in interface NotificationQueue.Dependency
      Parameters:
      step - The step for which we are testing satisfaction
      Returns:
      Whether the dependency is satisfied on step (and will not fire subsequent notifications)
    • getUpdateGraph

      public UpdateGraph getUpdateGraph()
      Specified by:
      getUpdateGraph in interface NotificationQueue.Dependency
      Returns:
      the update graph that this dependency is a part of
    • append

      public LogOutput append(@NotNull @NotNull LogOutput logOutput)
      Specified by:
      append in interface LogOutputAppendable