Skip to main content
Version: Java (Groovy)

TablePublisher

The TablePublisher class creates a blink table from tables that are added to it via the add method.

Syntax

TablePublisher.of(name, definition, onFlushCallback, onShutdownCallback)
TablePublisher.of(name, definition, onFlushCallback, onShutdownCallback, updateGraph, chunkSize)

Parameters

ParameterTypeDescription
nameString

The name of the table publisher.

definitionTableDefinition

The table definition.

onFlushCallbackConsumer

The on-flush callback. If not null, the consumer is called once at the beginning of each update cycle. It allows publishers to add any data that they may have been batching. It blocks the update cycle from proceeding, so implementations should take care not to do extraneous work.

onShutdownCallbackRunnable

The on-shutdown callback. If not null, the runnable is called one time when publishFailure is called.

updateGraphUpdateGraph

The update graph for the blink table.

chunkSizeint

The maximum chunk size. The default value is 2048.

Returns

A new TablePublisher.

Methods

TablePublisher supports the following methods:

  • add(table) - Adds a table to the blink table.
  • definition() - Gets the table definition.
  • isAlive() - Checks if the table publisher is alive.
  • publishFailure(failure) - Indicate that data publication has hailed. Listeners will be notified, the on-shutdown callback will be invoked (if it hasn't already been), and future calls to add will return without doing anything.
  • table() - Gets the blink table.

Examples

In this example, TablePublisher is used to create a blink table with three columns (X, Y, and Z). The columns are of type int, double, and double, respectively.

import io.deephaven.csv.util.MutableBoolean
import io.deephaven.engine.table.ColumnDefinition
import io.deephaven.engine.table.TableDefinition
import io.deephaven.stream.TablePublisher

definition = TableDefinition.of(
ColumnDefinition.ofInt("X"),
ColumnDefinition.ofDouble("Y"),
ColumnDefinition.ofDouble("Z")
)

shutDown = {println "Finished using My Publisher."}

onShutdown = new MutableBoolean()

publisher = TablePublisher.of("My Publisher", definition, null, shutDown)

source = publisher.table()

To add data to blink table, call add.

publisher.add(emptyTable(10).update("X = randomInt(-100, 100)", "Y = randomDouble(-5.0, 5.0)", "Z = randomDouble(100.0, 1000.0)"))

To shut the publisher down, call publishFailure.

publisher.publishFailure(new RuntimeException("Publisher shut down by user."))