Class BaseTable
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,NotificationQueue.Dependency
,Deflatable<Table>
,Table
,LivenessManager
,LivenessNode
,LivenessReferent
,LongSizedDataStructure
,DynamicNode
,DynamicTable
,NotificationStepReceiver
,NotificationStepSource
,SystemicObject
,Serializable
- Direct Known Subclasses:
QueryTable
,SubscriptionSnapshotTable
,UncoalescedTable
,WrappedDelegatingTable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
Simplest appropriate legacy InstrumentedListener implementation for BaseTable and descendants.static class
Simplest appropriate InstrumentedShiftAwareListener implementation for BaseTable and descendants.static interface
Nested classes/interfaces inherited from interface com.illumon.iris.db.tables.Table
Table.AsOfMatchRule, Table.GroupStrategy, Table.RenameFunction
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TableDefinition
This table's definition.protected final String
This table's description.static final boolean
protected boolean
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addParentReference
(Object parent) Called on a dependent node to ensure that a strong reference is maintained to any parent object that is required for the proper maintenance and functioning of the dependent.com.fishlib.base.log.LogOutput
append
(com.fishlib.base.log.LogOutput logOutput) void
Wait for updates to this DynamicTable.boolean
awaitUpdate
(long timeout) Wait for updates to this DynamicTable.Clear all sorting restrictions that was applied to the current table.copy()
Copies this table, but with a new set of attributes.void
copyAttributes
(Table dest, BaseTable.CopyAttributeOperation copyType) Copy this table's attributes to the specified table.void
copyAttributes
(Table dest, Predicate<String> shouldCopy) Copy this table's attributes to the specified table.<T extends SwapListenerBase>
TIf we are a refreshing table, then we should create a swap listener and listen for updates.protected void
destroy()
Attempt to release (destructively when necessary) resources held by this object.getAttribute
(String key) Get the value of the specified attribute.Get a set of all the attributes that have values for this table.getAttributes
(Collection<String> excludedAttrs) Get all attributes from the desired table except the items that appear in excluded.long
Get the last logical clock step on which this element dispatched a notification.protected NotificationQueue
Get the notification queue to insert notifications into as they are generated by listeners duringDynamicTable.notifyListeners(Index, Index, Index)
.boolean
hasAttribute
(String name) Check if the specified attribute exists in this table.<SL extends SwapListenerBase>
voidinitializeWithSnapshot
(String logPrefix, SL swapListener, ConstructSnapshot.SnapshotFunction snapshotFunction) boolean
Returns true if this table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.static boolean
Returns true if this provided table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.boolean
isFailed()
final boolean
Is the node updating?boolean
Returns true if this is a systemically important object (seeSystemicObjectTracker
).layoutHints
(String hints) void
listenForDirectUpdates
(Listener listener) Subscribe for updates to this table.void
listenForUpdates
(Listener listener, boolean replayInitialImage) Subscribe for updates to this table.void
listenForUpdates
(ShiftAwareListener listener) Subscribe for updates to this table.void
Mark this object as systemically important.final void
Initiate update delivery to this table's listeners.final void
notifyListenersOnError
(Throwable e, UpdatePerformanceTracker.Entry sourceEntry) Initiate failure delivery to this table's listeners.void
removeDirectUpdateListener
(Listener listenerToRemove) Unsubscribe the supplied listener.void
removeUpdateListener
(Listener listenerToRemove) Unsubscribe the supplied listener.void
removeUpdateListener
(ShiftAwareListener listenerToRemove) Unsubscribe the supplied listener.restrictSortTo
(String... allowedSortingColumns) Disallow sorting on all but the specified columns.boolean
satisfied
(long step) Is this ancestor satisfied? Note that this method must be safe to call on any thread.void
setAttribute
(String key, Object object) Set the value of an attribute.setColumnRenderers
(ColumnRenderersBuilder builder) Sets renderers for columns.void
setLastNotificationStep
(long lastNotificationStep) Deliver a last notification step to this receiver.final boolean
setRefreshing
(boolean refreshing) Change the node's refresh mode.setTotalsTable
(TotalsTableBuilder builder) Sets parameters for the default totals table display.protected static boolean
shouldCopyAttribute
(String attrName, BaseTable.CopyAttributeOperation copyType) toString()
withColumnDescription
(Map<String, String> descriptions) Add a set of column descriptions to the table.Set the table's key columns.withTableDescription
(String description) withUniqueKeys
(String... columns) Set the table's key columns and indicate that each key set will be unique.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, newModifiedColumnSet, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, notifyListeners, silent
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, size
Methods inherited from interface com.illumon.iris.db.tables.Table
absSumBy, absSumBy, absSumBy, absSumBy, aj, aj, aj, aj, aj, aj, apply, applyToAllBy, applyToAllBy, applyToAllBy, applyToAllBy, avgBy, avgBy, avgBy, avgBy, by, by, by, by, by, by, by, byExternal, byExternal, byteColumnIterator, characterColumnIterator, close, coalesce, columnIterator, countBy, countBy, countBy, countBy, dateTimeColumnAsNanos, dateTimeColumnAsNanos, deflate, deflate, doubleColumnIterator, dropColumnFormats, dropColumns, dropColumns, exactJoin, exactJoin, exactJoin, exactJoin, exactJoin, firstBy, firstBy, firstBy, firstBy, flatten, floatColumnIterator, formatColumns, formatColumnWhere, formatRowWhere, getAttributes, getColumn, getColumn, getColumns, getColumnSource, getColumnSource, getColumnSourceMap, getColumnSources, getIndex, getMeta, getRecord, getSubTable, getViewPort, hasColumns, hasColumns, head, headBy, headBy, headBy, headPct, integerColumnIterator, isEmpty, isFlat, isLive, join, join, join, join, join, join, join, join, join, join, lastBy, lastBy, lastBy, lastBy, layoutHints, lazyUpdate, lazyUpdate, lazyUpdate, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, longColumnIterator, maxBy, maxBy, maxBy, maxBy, medianBy, medianBy, medianBy, medianBy, minBy, minBy, minBy, minBy, moveColumns, moveColumns, moveDownColumns, moveUpColumns, naturalJoin, naturalJoin, naturalJoin, naturalJoin, naturalJoin, preemptiveSnapshotTable, preemptiveSnapshotTable, preemptiveUpdatesTable, raj, raj, raj, raj, raj, raj, releaseCachedResources, renameAllColumns, renameColumns, renameColumns, renameColumns, reverse, rollup, rollup, rollup, rollup, rollup, rollup, rollup, rollup, select, select, select, select, selectDistinct, selectDistinct, selectDistinct, selectDistinct, shortColumnIterator, sizeForInstrumentation, slice, snapshot, snapshot, snapshotHistory, snapshotIncremental, snapshotIncremental, sort, sort, sort, sortDescending, sortDescending, stdBy, stdBy, stdBy, stdBy, subscribeToPreemptiveUpdates, sumBy, sumBy, sumBy, sumBy, supportsPreemptiveSubscription, tail, tailBy, tailBy, tailBy, tailPct, treeTable, ungroup, ungroup, ungroup, ungroup, ungroupAllBut, update, update, update, updateBy, updateBy, updateBy, updateBy, updateBy, updateBy, updateView, updateView, updateView, validateSelect, validateSelect, varBy, varBy, varBy, varBy, view, view, view, wavgBy, wavgBy, wavgBy, wavgBy, where, where, where, where, whereIn, whereIn, whereIn, whereIn, whereNotIn, whereNotIn, whereOneOf, whereOneOf, whereOneOf, withColumnDescription, wouldMatch, wouldMatch, wsumBy, wsumBy, wsumBy, wsumBy
-
Field Details
-
PRINT_SERIALIZED_UPDATE_OVERLAPS
public static final boolean PRINT_SERIALIZED_UPDATE_OVERLAPS -
definition
This table's definition. -
description
This table's description. -
attributes
-
-
Constructor Details
-
BaseTable
-
BaseTable
public BaseTable(@NotNull TableDefinition definition, @NotNull String description, Map<String, Object> attributes)
-
-
Method Details
-
getDefinition
- Specified by:
getDefinition
in interfaceTable
-
getDescription
- Specified by:
getDescription
in interfaceTable
-
toString
- Overrides:
toString
in classReferenceCounted
-
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
append
in interfacecom.fishlib.base.log.LogOutputAppendable
- Overrides:
append
in classReferenceCounted
-
setAttribute
Description copied from interface:Table
Set the value of an attribute.- Specified by:
setAttribute
in interfaceTable
- Parameters:
key
- the name of the attributeobject
- the value
-
getAttribute
Description copied from interface:Table
Get the value of the specified attribute.- Specified by:
getAttribute
in interfaceTable
- Parameters:
key
- the name of the attribute- Returns:
- the value, or null if there was none.
-
getAttributeNames
Description copied from interface:Table
Get a set of all the attributes that have values for this table.- Specified by:
getAttributeNames
in interfaceTable
- Returns:
- a set of names
-
hasAttribute
Description copied from interface:Table
Check if the specified attribute exists in this table.- Specified by:
hasAttribute
in interfaceTable
- Parameters:
name
- the name of the attribute- Returns:
- true if the attribute exists
-
getAttributes
Description copied from interface:Table
Get all attributes from the desired table except the items that appear in excluded.- Specified by:
getAttributes
in interfaceTable
- Parameters:
excludedAttrs
- A set of attributes to exclude from the result- Returns:
- All of the table's attributes except the ones present in excluded
-
shouldCopyAttribute
protected static boolean shouldCopyAttribute(String attrName, BaseTable.CopyAttributeOperation copyType) -
copyAttributes
Copy this table's attributes to the specified table. Attributes will be copied based upon the inputBaseTable.CopyAttributeOperation
.- Parameters:
dest
- The table to copy attributes tocopyType
- The operation being performed that requires attributes to be copied.
-
copyAttributes
Copy this table's attributes to the specified table. Attributes are copied based on a predicate.- Parameters:
dest
- The table to copy attributes toshouldCopy
- should we copy this attribute?
-
isAddOnly
public boolean isAddOnly()Returns true if this table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.- Returns:
- true if this table does not produce modifications, shifts, or removals
-
isAddOnly
Returns true if this provided table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.- Returns:
- true if the table does not produce modifications, shifts, or removals
-
addParentReference
Description copied from interface:DynamicNode
Called on a dependent node to ensure that a strong reference is maintained to any parent object that is required for the proper maintenance and functioning of the dependent. In the most common case, the parent object is a child listener to a parent node. The parent node only keeps a weak reference to its child listener, but the listener maintains a strong reference to the parent node. In this scenario, the only strong reference to the listener (and thus indirectly to the parent node itself) is the reference kept by the dependent node.- Specified by:
addParentReference
in interfaceDynamicNode
- Parameters:
parent
- A parent of this node
-
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 interfaceNotificationQueue.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)
-
awaitUpdate
Description copied from interface:DynamicTable
Wait for updates to this DynamicTable.
In some implementations, this call may also terminate in case of interrupt or spurious wakeup (see java.util.concurrent.locks.Condition#await()).
- Specified by:
awaitUpdate
in interfaceDynamicTable
- Throws:
InterruptedException
- In the event this thread is interrupted
-
awaitUpdate
Description copied from interface:DynamicTable
Wait for updates to this DynamicTable.
In some implementations, this call may also terminate in case of interrupt or spurious wakeup (see java.util.concurrent.locks.Condition#await()).
- Specified by:
awaitUpdate
in interfaceDynamicTable
- Parameters:
timeout
- The maximum time to wait in milliseconds.- Returns:
- false if the timeout elapses without notification, true otherwise.
- Throws:
InterruptedException
- In the event this thread is interrupted
-
listenForUpdates
Description copied from interface:DynamicTable
Subscribe for updates to this table. After the optional initial image, listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.- Specified by:
listenForUpdates
in interfaceDynamicTable
- Parameters:
listener
- listener for updatesreplayInitialImage
- true to process updates for all initial rows in the table plus all new row changes; false to only process new row changes
-
listenForUpdates
Description copied from interface:DynamicTable
Subscribe for updates to this table. Listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.- Specified by:
listenForUpdates
in interfaceDynamicTable
- Parameters:
listener
- listener for updates
-
listenForDirectUpdates
Description copied from interface:DynamicTable
Subscribe for updates to this table. Direct listeners are invoked immediately when changes are published, rather than via a LiveTableMonitor notification queue.- Specified by:
listenForDirectUpdates
in interfaceDynamicTable
- Parameters:
listener
- listener for updates
-
removeUpdateListener
Description copied from interface:DynamicTable
Unsubscribe the supplied listener.- Specified by:
removeUpdateListener
in interfaceDynamicTable
- Parameters:
listenerToRemove
- listener for updates
-
removeUpdateListener
Description copied from interface:DynamicTable
Unsubscribe the supplied listener.- Specified by:
removeUpdateListener
in interfaceDynamicTable
- Parameters:
listenerToRemove
- listener for updates
-
removeDirectUpdateListener
Description copied from interface:DynamicTable
Unsubscribe the supplied listener.- Specified by:
removeDirectUpdateListener
in interfaceDynamicTable
- Parameters:
listenerToRemove
- listener for updates
-
notifyListenersOnError
public final void notifyListenersOnError(Throwable e, @Nullable UpdatePerformanceTracker.Entry sourceEntry) Description copied from interface:DynamicTable
Initiate failure delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.- Specified by:
notifyListenersOnError
in interfaceDynamicTable
- Parameters:
e
- errorsourceEntry
- performance tracking
-
isRefreshing
public final boolean isRefreshing()Description copied from interface:DynamicNode
Is the node updating?- Specified by:
isRefreshing
in interfaceDynamicNode
- Returns:
- true if the node is updating; false otherwise.
-
setRefreshing
public final boolean setRefreshing(boolean refreshing) Description copied from interface:DynamicNode
Change the node's refresh mode.- Specified by:
setRefreshing
in interfaceDynamicNode
- Parameters:
refreshing
- true to cause the node to update; false otherwise.- Returns:
- new refreshing state
-
isFailed
public boolean isFailed()- Specified by:
isFailed
in interfaceDynamicTable
- Returns:
- true if this table is in a failure state.
-
notifyListeners
Description copied from interface:DynamicTable
Initiate update delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.- Specified by:
notifyListeners
in interfaceDynamicTable
- Parameters:
update
- the set of table changes to propagate The caller gives this update object away; the invocation ofnotifyListeners
takes ownership, and will callrelease
on it once it is not used anymore; callers should pass aclone
for updates they intend to further use.
-
getNotificationQueue
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.- Returns:
- The
NotificationQueue
to add to.
-
getLastNotificationStep
public long getLastNotificationStep()Description copied from interface:NotificationStepSource
Get the last logical clock step on which this element dispatched a notification.- Specified by:
getLastNotificationStep
in interfaceNotificationStepSource
- Returns:
- The last notification step
-
setLastNotificationStep
public void setLastNotificationStep(long lastNotificationStep) Description copied from interface:NotificationStepReceiver
Deliver a last notification step to this receiver.- Specified by:
setLastNotificationStep
in interfaceNotificationStepReceiver
- Parameters:
lastNotificationStep
- The last notification step to be delivered
-
isSystemicObject
public boolean isSystemicObject()Description copied from interface:SystemicObject
Returns true if this is a systemically important object (seeSystemicObjectTracker
).- Specified by:
isSystemicObject
in interfaceSystemicObject
- Returns:
- true if this is a systemically important object, false otherwise.
-
markSystemic
public void markSystemic()Description copied from interface:SystemicObject
Mark this object as systemically important.- Specified by:
markSystemic
in interfaceSystemicObject
-
withKeys
Description copied from interface:Table
Set the table's key columns. -
withUniqueKeys
Description copied from interface:Table
Set the table's key columns and indicate that each key set will be unique.- Specified by:
withUniqueKeys
in interfaceTable
- Returns:
- The same table this method was invoked on, with the keyColumns and unique attributes set
-
restrictSortTo
Description copied from interface:Table
Disallow sorting on all but the specified columns.
- Specified by:
restrictSortTo
in interfaceTable
- Parameters:
allowedSortingColumns
- The columns on which sorting is allowed.- Returns:
- The same table this was invoked on.
-
clearSortingRestrictions
Description copied from interface:Table
Clear all sorting restrictions that was applied to the current table.
Note that this table operates on the table it was invoked on and does not create a new table. So in the following code
T1 = baseTable.where(...) T2 = T1.restrictSortTo("C1") T3 = T2.clearSortingRestrictions()
T1 == T2 == T3 and the result has no restrictions on sorting.- Specified by:
clearSortingRestrictions
in interfaceTable
- Returns:
- The same table this was invoked on.
-
layoutHints
- Specified by:
layoutHints
in interfaceTable
-
copy
Copies this table, but with a new set of attributes.- Returns:
- an identical table; but with a new set of attributes
-
setTotalsTable
Description copied from interface:Table
Sets parameters for the default totals table display.- Specified by:
setTotalsTable
in interfaceTable
- Parameters:
builder
- aTotalsTableBuilder
object- Returns:
- a table with the totals applied
-
setColumnRenderers
Description copied from interface:Table
Sets renderers for columns.- Specified by:
setColumnRenderers
in interfaceTable
- Parameters:
builder
- a builder that creates the packed string for the attribute- Returns:
- The same table with the ColumnRenderes attribute set
-
initializeWithSnapshot
public <SL extends SwapListenerBase> void initializeWithSnapshot(String logPrefix, SL swapListener, ConstructSnapshot.SnapshotFunction snapshotFunction) -
createSwapListenerIfRefreshing
@Nullable public <T extends SwapListenerBase> T createSwapListenerIfRefreshing(BaseTable.SwapListenerFactory<T> factory) If we are a refreshing table, then we should create a swap listener and listen for updates. Otherwise, we return null.- Returns:
- a swap listener for this table (or null)
-
destroy
protected void destroy()Description copied from class:ReferenceCountedLivenessNode
Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
- Overrides:
destroy
in classReferenceCountedLivenessNode
-
withTableDescription
- Specified by:
withTableDescription
in interfaceTable
-
withColumnDescription
Description copied from interface:Table
Add a set of column descriptions to the table.- Specified by:
withColumnDescription
in interfaceTable
- Parameters:
descriptions
- a map of Column name to Column description.- Returns:
- a copy of the table with the descriptions applied.
-