Package com.illumon.iris.db.v2.remote
Class ReplicatedTable
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,LiveTable
,NotificationQueue.Dependency
,Deflatable<Table>
,Table
,LivenessManager
,LivenessNode
,LivenessReferent
,LongSizedDataStructure
,DynamicNode
,DynamicTable
,NotificationStepReceiver
,NotificationStepSource
,SystemicObject
,Closeable
,Serializable
,AutoCloseable
,Runnable
A client side viewport of a server side Table
. This is backed by a RemoteTableHandle.TableProxy
which is in turn backed by a RemoteTableHandle
. Clients may request a client id
to set
a specific viewport. This class will subscribe to updates for all of the specified rows and columns in all set viewports.
Note that in this case viewport is defined as a set of positions into the original table.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A listener for population events within this table.Nested classes/interfaces inherited from class com.illumon.iris.db.v2.remote.InitialSnapshotTable
InitialSnapshotTable.Setter<T>
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.QueryTable
QueryTable.FilteredTable, QueryTable.MemoizableOperation, QueryTable.Operation
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.BaseTable
BaseTable.CopyAttributeOperation, BaseTable.ListenerImpl, BaseTable.ShiftAwareListenerImpl, BaseTable.SwapListenerFactory<T extends SwapListenerBase>
Nested classes/interfaces inherited from interface com.illumon.iris.db.tables.Table
Table.AsOfMatchRule, Table.GroupStrategy, Table.RenameFunction
-
Field Summary
FieldsFields inherited from class com.illumon.iris.db.v2.remote.InitialSnapshotTable
capacity, freeset, populatedCells, populatedRows, setters
Fields inherited from class com.illumon.iris.db.v2.QueryTable
modifiedColumnSet, USE_CHUNKED_CROSS_JOIN, USE_UNTRACKED_LASTBY_FOR_AUTOMATED_FILTERS
Fields inherited from class com.illumon.iris.db.v2.BaseTable
attributes, definition, description, PRINT_SERIALIZED_UPDATE_OVERLAPS, sharedAttributes
Fields inherited from interface com.illumon.iris.db.v2.NotificationStepReceiver
NULL_NOTIFICATION_STEP
Fields inherited from interface com.illumon.iris.db.tables.Table
ACL_ATTRIBUTE, ADD_ONLY_TABLE_ATTRIBUTE, COLUMN_DESCRIPTIONS_ATTRIBUTE, COLUMN_RENDERERS_ATTRIBUTE, CUSTOM_ACTIONS_ATTRIBUTE, DO_NOT_MAKE_REMOTE_ATTRIBUTE, EMPTY_SOURCE_TABLE_ATTRIBUTE, FILTERABLE_COLUMNS_ATTRIBUTE, HIERARCHICAL_CHILDREN_TABLE_MAP_ATTRIBUTE, HIERARCHICAL_SOURCE_INFO_ATTRIBUTE, HIERARCHICAL_SOURCE_TABLE_ATTRIBUTE, INPUT_TABLE_ATTRIBUTE, KEY_COLUMNS_ATTRIBUTE, LAYOUT_HINTS_ATTRIBUTE, MERGED_TABLE_ATTRIBUTE, NON_DISPLAY_TABLE, PLUGIN_NAME, PREDEFINED_ROLLUP_ATTRIBUTE, PREEMPTIVE_VIEWPORT_TYPE, PREPARED_RLL_ATTRIBUTE, PREVIEW_PARENT_TABLE, REVERSE_LOOKUP_ATTRIBUTE, ROLLUP_LEAF_ATTRIBUTE, SNAPSHOT_VIEWPORT_TYPE, SORTABLE_COLUMNS_ATTRIBUTE, SORTED_COLUMNS_ATTRIBUTE, SYSTEMIC_TABLE_ATTRIBUTE, TABLE_DESCRIPTION_ATTRIBUTE, TOTALS_TABLE_ATTRIBUTE, TREE_TABLE_FILTER_REVERSE_LOOKUP_ATTRIBUTE, UNIQUE_KEYS_ATTRIBUTE, UNTRACKED_LASTBY_TABLE_ATTRIBUTE, VIEWPORT_TYPE_ATTRIBUTE, ZERO_LENGTH_TABLE_ARRAY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ReplicatedTable
(com.fishlib.io.logger.Logger log, LiveTableRegistrar registrar, NotificationQueue notificationQueue, int subscriptionId, RemoteTableHandle.TableProxy tableProxy, LinkedHashMap<String, ColumnSource> columns, WritableSource[] writableSources, RedirectionIndex redirectionIndex, BitSet subscribedColumns, boolean isViewPort) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Listen for population events.com.fishlib.base.log.LogOutput
append
(com.fishlib.base.log.LogOutput logOutput) void
close()
Release resources held by this table, possibly destructively.void
Enqueue an error to be reported on the next refresh cycle.void
freeze()
Freeze the table.getAttribute
(String key) Get the value of the specified attribute.protected NotificationQueue
Get the notification queue to insert notifications into as they are generated by listeners duringDynamicTable.notifyListeners(Index, Index, Index)
.Get the set of populated rows in Key space.long
Get theRemoteTableHandle
backing thisReplicatedTable
int
Get the subscription ID of this table with the server.Get theRemoteTableHandle.TableProxy
backing this replicated table.boolean
Check if this table has beenunsubscribed
.int
Allocate and return a new viewport client ID for use withsetViewPort(int, Index)
and it's overrides.Get the current positional viewport index.void
handleUpdate
(DeltaUpdates deltaUpdates) boolean
hasAttribute
(String name) Check if the specified attribute exists in this table.boolean
isColumnFullyPopulated
(int column) Check if the column specified is fully populated.boolean
isPopulated
(long position, int column) Check if the specified position is populated.boolean
isPopulated
(long row, BitSet columns) Check if All of the columns in the specified row are populated.boolean
isPopulated
(Index rows, BitSet columns) Check if All of the columns in the specified row are populated.boolean
Check if this table is a viewport.protected static LinkedHashMap<String,
ColumnSource> makeColumns
(com.illumon.dataobjects.ColumnDefinition[] columns, WritableSource[] writableSources, RedirectionIndex emptyRedirectionIndex) Setup the columns for the replicated table.void
refresh()
Refresh this LiveTable.void
Remove the specified listener from notifications.void
removeViewportClient
(int client) Remove the specified client from the set of viewports.void
setColumnUpdateSnapshot
(InitialSnapshot updateSnapshot) void
setInitialSnapshot
(InitialSnapshot initialSnapshot) void
setReplacementSnapshot
(InitialSnapshot replacementSnapshot) void
setRowUpdateSnapshot
(InitialSnapshot updateSnapshot) void
Set this table as unsubscribed.static ReplicatedTable
setupForUnitTests
(com.fishlib.io.logger.Logger log, LiveTableRegistrar registrar, NotificationQueue notificationQueue, RemoteTableHandle.TableProxy tableProxy, int tableId, Table tablePrototype, boolean isViewPort) static ReplicatedTable
setupReplicatedTable
(com.fishlib.io.logger.Logger log, int tableId, RemoteTableHandle.TableProxy tableProxy, BitSet subscribedColumns, boolean isViewPort) Set up a Replicated table from the given proxy, id and columns.void
setViewPort
(int client, long firstPosition, long lastPosition) Set the row viewport for the specified client.void
setViewPort
(int client, Index newViewPort) Set the positional viewport for a particular clientvoid
setViewportAndColumns
(int client, long firstPosition, long lastPosition, BitSet columns) Set the row and column viewport for the specified client.void
setViewportAndColumns
(int client, Index newViewPort, BitSet columns) Set the positional viewport and relevant columns for the specified clientvoid
suspendViewportClient
(int client) Suspend the viewport for a particular client.toString()
void
Unsubscribe this table from the server.void
updateColumnSubscriptions
(int client, BitSet newColumns) Set the set of columns subscribed for the specified client id.void
Wait for initial data to be available.void
Wait for all of the columns and rows in the viewport to become populated.void
waitForPopulation
(long position, int column) Waits for the specified position to become populated.void
waitForPopulation
(Index positions, BitSet columns) Waits for all of the columns in the specified positions to become populated.Methods inherited from class com.illumon.iris.db.v2.remote.InitialSnapshotTable
getFreeRows, getSetter, getSubscribedColumns, isSubscribedColumn, processInitialSnapshot, setupInitialSnapshotTable, setupInitialSnapshotTable, setupInitialSnapshotTable, setupInitialSnapshotTable
Methods inherited from class com.illumon.iris.db.v2.QueryTable
absSumBy, aj, apply, applyToAllBy, avgBy, by, byExternal, copy, copy, countBy, disableParallelWhereForThread, disableWriteReplace, dropColumns, enableWriteReplace, exactJoin, firstBy, flatten, getColumn, getColumnSource, getColumnSourceMap, getColumnSources, getDataIndex, getIndex, getModifiedColumnSetForUpdates, getRecord, getSubTable, getSubTable, head, headBy, headPct, isFlat, join, lastBy, lazyUpdate, leftJoin, maxBy, medianBy, memoizeResult, minBy, naturalJoin, newModifiedColumnSet, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetTransformer, preemptiveSnapshotTable, preemptiveUpdatesTable, preemptiveUpdatesTable, raj, releaseCachedResources, renameColumns, reverse, rollup, select, selectDistinct, setDataIndexProvider, setFlat, setMemoizeResults, silent, size, slice, snapshot, snapshotHistory, snapshotIncremental, sort, stdBy, sumBy, tail, tailBy, tailPct, treeTable, ungroup, update, updateBy, updateView, validateSelect, varBy, view, wavgBy, where, whereIn, wouldMatch, wsumBy
Methods inherited from class com.illumon.iris.db.v2.BaseTable
addParentReference, awaitUpdate, awaitUpdate, clearSortingRestrictions, copyAttributes, copyAttributes, createSwapListenerIfRefreshing, destroy, getAttributeNames, getAttributes, getDefinition, getDescription, getLastNotificationStep, initializeWithSnapshot, isAddOnly, isAddOnly, isFailed, isRefreshing, isSystemicObject, layoutHints, listenForDirectUpdates, listenForUpdates, listenForUpdates, markSystemic, notifyListeners, notifyListenersOnError, removeDirectUpdateListener, removeUpdateListener, removeUpdateListener, restrictSortTo, satisfied, setAttribute, setColumnRenderers, setLastNotificationStep, setRefreshing, setTotalsTable, shouldCopyAttribute, withColumnDescription, withKeys, withTableDescription, withUniqueKeys
Methods inherited from class com.illumon.iris.db.util.liveness.LivenessArtifact
manageWithCurrentScope, unmanage, unmanage
Methods inherited from class com.illumon.iris.db.util.liveness.ReferenceCountedLivenessNode
dropReference, getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryRetainReference
Methods inherited from class com.illumon.util.referencecounting.ReferenceCounted
decrementReferenceCount, incrementReferenceCount, resetReferenceCount, tryDecrementReferenceCount, tryIncrementReferenceCount
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.DynamicTable
listenForUpdates, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, notifyListeners
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessManager
manage, tryManage
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReference
Methods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSize
Methods inherited from interface com.illumon.iris.db.tables.Table
absSumBy, absSumBy, absSumBy, aj, aj, aj, aj, aj, applyToAllBy, applyToAllBy, applyToAllBy, avgBy, avgBy, avgBy, by, by, by, by, by, by, byExternal, byteColumnIterator, characterColumnIterator, coalesce, columnIterator, countBy, countBy, countBy, dateTimeColumnAsNanos, dateTimeColumnAsNanos, deflate, deflate, doubleColumnIterator, dropColumnFormats, dropColumns, exactJoin, exactJoin, exactJoin, exactJoin, firstBy, firstBy, firstBy, floatColumnIterator, formatColumns, formatColumnWhere, formatRowWhere, getAttributes, getColumn, getColumns, getColumnSource, getMeta, getViewPort, hasColumns, hasColumns, headBy, headBy, integerColumnIterator, isEmpty, isLive, join, join, join, join, join, join, join, join, join, lastBy, lastBy, lastBy, layoutHints, lazyUpdate, lazyUpdate, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, longColumnIterator, maxBy, maxBy, maxBy, medianBy, medianBy, medianBy, minBy, minBy, minBy, moveColumns, moveColumns, moveDownColumns, moveUpColumns, naturalJoin, naturalJoin, naturalJoin, naturalJoin, preemptiveSnapshotTable, raj, raj, raj, raj, raj, renameAllColumns, renameColumns, renameColumns, rollup, rollup, rollup, rollup, rollup, rollup, rollup, select, select, select, selectDistinct, selectDistinct, selectDistinct, shortColumnIterator, sizeForInstrumentation, snapshot, snapshotIncremental, sort, sort, sortDescending, sortDescending, stdBy, stdBy, stdBy, subscribeToPreemptiveUpdates, sumBy, sumBy, sumBy, supportsPreemptiveSubscription, tailBy, tailBy, ungroup, ungroup, ungroup, ungroupAllBut, update, update, updateBy, updateBy, updateBy, updateBy, updateBy, updateView, updateView, validateSelect, varBy, varBy, varBy, view, view, wavgBy, wavgBy, wavgBy, where, where, where, whereIn, whereIn, whereIn, whereNotIn, whereNotIn, whereOneOf, whereOneOf, whereOneOf, withColumnDescription, wouldMatch, wsumBy, wsumBy, wsumBy
-
Field Details
-
REPLICATED_TABLE_DEBUG
public static final boolean REPLICATED_TABLE_DEBUG
-
-
Constructor Details
-
ReplicatedTable
protected ReplicatedTable(com.fishlib.io.logger.Logger log, LiveTableRegistrar registrar, NotificationQueue notificationQueue, int subscriptionId, @NotNull RemoteTableHandle.TableProxy tableProxy, LinkedHashMap<String, ColumnSource> columns, WritableSource[] writableSources, RedirectionIndex redirectionIndex, BitSet subscribedColumns, boolean isViewPort)
-
-
Method Details
-
getProcessedDelta
public long getProcessedDelta() -
setInitialSnapshot
-
setReplacementSnapshot
-
setColumnUpdateSnapshot
-
setRowUpdateSnapshot
-
getSubscriptionId
public int getSubscriptionId()Get the subscription ID of this table with the server. This ID can be used to retrieve the table on the server within aRemoteQuery
- Returns:
- the id of this table for use with queries to the server
-
handleUpdate
-
refresh
public void refresh()Description copied from interface:LiveTable
Refresh this LiveTable. -
getNotificationQueue
Description copied from class:BaseTable
Get the notification queue to insert notifications into as they are generated by listeners duringDynamicTable.notifyListeners(Index, Index, Index)
. This method may be overridden to provide a different notification queue than theLiveTableMonitor.DEFAULT
instance for more complex behavior.- Overrides:
getNotificationQueue
in classBaseTable
- Returns:
- The
NotificationQueue
to add to.
-
freeze
public void freeze()Freeze the table. This will stop all update propagation. -
close
public void close()Description copied from interface:Table
Release resources held by this table, possibly destructively. This may render the table unsuitable or unsafe for further use. -
unsubscribe
public void unsubscribe()Unsubscribe this table from the server. The table will no longer be usable afterwards -
updateColumnSubscriptions
Set the set of columns subscribed for the specified client id.- Parameters:
client
- the client idnewColumns
- the columns that should be subscribed.
-
getViewportClientId
public int getViewportClientId()Allocate and return a new viewport client ID for use withsetViewPort(int, Index)
and it's overrides.- Returns:
- the newly allocated client id.
-
setViewPort
public void setViewPort(int client, long firstPosition, long lastPosition) Set the row viewport for the specified client.- Parameters:
client
- the client idfirstPosition
- the first position in the viewportlastPosition
- the last position in the viewport (exclusive)
-
setViewportAndColumns
public void setViewportAndColumns(int client, long firstPosition, long lastPosition, BitSet columns) Set the row and column viewport for the specified client.- Parameters:
client
- the client idfirstPosition
- the first position in the viewportlastPosition
- the last position in the viewport (exclusive)columns
- the columns in the viewport
-
removeViewportClient
public void removeViewportClient(int client) Remove the specified client from the set of viewports. This will remove any subscribed viewports for this client.- Parameters:
client
- the client to remove.
-
suspendViewportClient
public void suspendViewportClient(int client) Suspend the viewport for a particular client. Suspended viewports will not receive updates- Parameters:
client
- the client to suspend
-
setViewPort
Set the positional viewport for a particular client- Parameters:
client
- the client idnewViewPort
- the viewport for this client
-
setViewportAndColumns
Set the positional viewport and relevant columns for the specified client- Parameters:
client
- the client idnewViewPort
- the positional viewportcolumns
- the columns to include
-
getUnsubscribed
public boolean getUnsubscribed()Check if this table has beenunsubscribed
.- Returns:
- true if the table has been unsubscribed
-
setUnsubscribed
public void setUnsubscribed()Set this table as unsubscribed. -
enqueueError
Enqueue an error to be reported on the next refresh cycle.- Parameters:
e
- The error
-
getTableProxy
Get theRemoteTableHandle.TableProxy
backing this replicated table.- Returns:
- the backing proxy
-
setupReplicatedTable
@InternalUseOnly public static ReplicatedTable setupReplicatedTable(com.fishlib.io.logger.Logger log, int tableId, @NotNull RemoteTableHandle.TableProxy tableProxy, BitSet subscribedColumns, boolean isViewPort) Set up a Replicated table from the given proxy, id and columns. This is intended for Deephaven use only.- Parameters:
log
- a loggertableId
- the table ID from the pqtableProxy
- the proxy to the original tablesubscribedColumns
- a bitset of columns that are subscribedisViewPort
- true if the table will be a viewport.- Returns:
- a properly initialized
ReplicatedTable
-
setupForUnitTests
@TestUseOnly public static ReplicatedTable setupForUnitTests(com.fishlib.io.logger.Logger log, LiveTableRegistrar registrar, NotificationQueue notificationQueue, @NotNull RemoteTableHandle.TableProxy tableProxy, int tableId, Table tablePrototype, boolean isViewPort) -
makeColumns
@NotNull protected static LinkedHashMap<String,ColumnSource> makeColumns(com.illumon.dataobjects.ColumnDefinition[] columns, WritableSource[] writableSources, RedirectionIndex emptyRedirectionIndex) Setup the columns for the replicated table. NB: Your emptyRedirectionIndex must be initialized and empty. -
waitForData
public void waitForData()Wait for initial data to be available. This method will block. -
waitForPopulation
public void waitForPopulation(long position, int column) Waits for the specified position to become populated. This method automatically converts the specified position into the table's keyspace.- Parameters:
position
- the positioncolumn
- the column
-
waitForPopulation
public void waitForPopulation()Wait for all of the columns and rows in the viewport to become populated. -
waitForPopulation
Waits for all of the columns in the specified positions to become populated. This method automatically converts the specified positions into the table's keyspace.- Parameters:
positions
- the rows to inspectcolumns
- a BitSet of column indices to check for population
-
isViewPort
public boolean isViewPort()Check if this table is a viewport. A viewport table is a partial view of another table. If this returns false then this table contains the entire source table it was based on.- Returns:
- true if this table was a viewport.
-
isPopulated
public boolean isPopulated(long position, int column) Check if the specified position is populated. This method automatically converts the specified position into the table's keyspace.- Parameters:
position
- the positioncolumn
- the column- Returns:
- true of it has been populated
-
getViewportIndex
Get the current positional viewport index. If this ReplicatedTable is a viewport for another table (see ...) then this returns the union of all viewports from all clients. Otherwise it returns a flat set of positions from 0 - tableSize -1;- Returns:
- an index of viewport positions
-
getPopulatedRows
Get the set of populated rows in Key space.- Returns:
- the populated keys.
-
isPopulated
Check if All of the columns in the specified row are populated. Note that the input row index is expected to be in position space. It is internally converted to the table's keyspace.- Parameters:
row
- The row to inspectcolumns
- a BitSet of column indices to check for population
-
isPopulated
Check if All of the columns in the specified row are populated. Note that the input row index is expected to be in position space. It is internally converted to the table's keyspace.- Parameters:
rows
- the rows to inspectcolumns
- a BitSet of column indices to check for population
-
isColumnFullyPopulated
public boolean isColumnFullyPopulated(int column) Check if the column specified is fully populated.- Parameters:
column
- the column index- Returns:
- true if the column is completely populated.
-
getAttribute
Description copied from interface:Table
Get the value of the specified attribute.- Specified by:
getAttribute
in interfaceTable
- Overrides:
getAttribute
in classBaseTable
- Parameters:
key
- the name of the attribute- Returns:
- the value, or null if there was none.
-
hasAttribute
Description copied from interface:Table
Check if the specified attribute exists in this table.- Specified by:
hasAttribute
in interfaceTable
- Overrides:
hasAttribute
in classBaseTable
- Parameters:
name
- the name of the attribute- Returns:
- true if the attribute exists
-
addPopulationListener
Listen for population events. Note that these are stored asWeakReference
s, so you must retain a reference to them somewhere or they will be reclaimed by the garbage collector.- Parameters:
listener
- the listener
-
removePopulationListener
Remove the specified listener from notifications.- Parameters:
listener
- the listener to remove
-
getRemoteTableHandle
Get theRemoteTableHandle
backing thisReplicatedTable
- Returns:
- the RemoteTableHandle.
-
toString
-
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput)
-