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 enumstatic classSimplest appropriate legacy InstrumentedListener implementation for BaseTable and descendants.static classSimplest appropriate InstrumentedShiftAwareListener implementation for BaseTable and descendants.static interfaceNested classes/interfaces inherited from interface com.illumon.iris.db.tables.Table
Table.AsOfMatchRule, Table.GroupStrategy, Table.RenameFunction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TableDefinitionThis table's definition.protected final StringThis table's description.static final booleanprotected booleanFields inherited from interface com.illumon.iris.db.v2.NotificationStepReceiver
NULL_NOTIFICATION_STEPFields 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 voidaddParentReference(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.LogOutputappend(com.fishlib.base.log.LogOutput logOutput) voidWait for updates to this DynamicTable.booleanawaitUpdate(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.voidcopyAttributes(Table dest, BaseTable.CopyAttributeOperation copyType) Copy this table's attributes to the specified table.voidcopyAttributes(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 voiddestroy()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.longGet the last logical clock step on which this element dispatched a notification.protected NotificationQueueGet the notification queue to insert notifications into as they are generated by listeners duringDynamicTable.notifyListeners(Index, Index, Index).booleanhasAttribute(String name) Check if the specified attribute exists in this table.<SL extends SwapListenerBase>
voidinitializeWithSnapshot(String logPrefix, SL swapListener, ConstructSnapshot.SnapshotFunction snapshotFunction) booleanReturns true if this table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.static booleanReturns true if this provided table is static, or has an attribute asserting that no modifies, shifts, or removals are generated.booleanisFailed()final booleanIs the node updating?booleanReturns true if this is a systemically important object (seeSystemicObjectTracker).layoutHints(String hints) voidlistenForDirectUpdates(Listener listener) Subscribe for updates to this table.voidlistenForUpdates(Listener listener, boolean replayInitialImage) Subscribe for updates to this table.voidlistenForUpdates(ShiftAwareListener listener) Subscribe for updates to this table.voidMark this object as systemically important.final voidInitiate update delivery to this table's listeners.final voidnotifyListenersOnError(Throwable e, UpdatePerformanceTracker.Entry sourceEntry) Initiate failure delivery to this table's listeners.voidremoveDirectUpdateListener(Listener listenerToRemove) Unsubscribe the supplied listener.voidremoveUpdateListener(Listener listenerToRemove) Unsubscribe the supplied listener.voidremoveUpdateListener(ShiftAwareListener listenerToRemove) Unsubscribe the supplied listener.restrictSortTo(String... allowedSortingColumns) Disallow sorting on all but the specified columns.booleansatisfied(long step) Is this ancestor satisfied? Note that this method must be safe to call on any thread.voidsetAttribute(String key, Object object) Set the value of an attribute.setColumnRenderers(ColumnRenderersBuilder builder) Sets renderers for columns.voidsetLastNotificationStep(long lastNotificationStep) Deliver a last notification step to this receiver.final booleansetRefreshing(boolean refreshing) Change the node's refresh mode.setTotalsTable(TotalsTableBuilder builder) Sets parameters for the default totals table display.protected static booleanshouldCopyAttribute(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, unmanageMethods inherited from class com.illumon.iris.db.util.liveness.ReferenceCountedLivenessNode
dropReference, getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryRetainReferenceMethods inherited from class com.illumon.util.referencecounting.ReferenceCounted
decrementReferenceCount, incrementReferenceCount, resetReferenceCount, tryDecrementReferenceCount, tryIncrementReferenceCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.illumon.iris.db.v2.DynamicTable
listenForUpdates, newModifiedColumnSet, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, notifyListeners, silentMethods inherited from interface com.illumon.iris.db.util.liveness.LivenessManager
manage, tryManageMethods inherited from interface com.illumon.iris.db.util.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReferenceMethods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSize, sizeMethods 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:
getDefinitionin interfaceTable
-
getDescription
- Specified by:
getDescriptionin interfaceTable
-
toString
- Overrides:
toStringin classReferenceCounted
-
append
public com.fishlib.base.log.LogOutput append(@NotNull com.fishlib.base.log.LogOutput logOutput) - Specified by:
appendin interfacecom.fishlib.base.log.LogOutputAppendable- Overrides:
appendin classReferenceCounted
-
setAttribute
Description copied from interface:TableSet the value of an attribute.- Specified by:
setAttributein interfaceTable- Parameters:
key- the name of the attributeobject- the value
-
getAttribute
Description copied from interface:TableGet the value of the specified attribute.- Specified by:
getAttributein interfaceTable- Parameters:
key- the name of the attribute- Returns:
- the value, or null if there was none.
-
getAttributeNames
Description copied from interface:TableGet a set of all the attributes that have values for this table.- Specified by:
getAttributeNamesin interfaceTable- Returns:
- a set of names
-
hasAttribute
Description copied from interface:TableCheck if the specified attribute exists in this table.- Specified by:
hasAttributein interfaceTable- Parameters:
name- the name of the attribute- Returns:
- true if the attribute exists
-
getAttributes
Description copied from interface:TableGet all attributes from the desired table except the items that appear in excluded.- Specified by:
getAttributesin 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:DynamicNodeCalled 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:
addParentReferencein interfaceDynamicNode- Parameters:
parent- A parent of this node
-
satisfied
public boolean satisfied(long step) Description copied from interface:NotificationQueue.DependencyIs this ancestor satisfied? Note that this method must be safe to call on any thread.- Specified by:
satisfiedin 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:DynamicTableWait 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:
awaitUpdatein interfaceDynamicTable- Throws:
InterruptedException- In the event this thread is interrupted
-
awaitUpdate
Description copied from interface:DynamicTableWait 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:
awaitUpdatein 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:DynamicTableSubscribe 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:
listenForUpdatesin 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:DynamicTableSubscribe for updates to this table. Listener will be invoked via the LiveTableMonitor notification queue associated with this DynamicTable.- Specified by:
listenForUpdatesin interfaceDynamicTable- Parameters:
listener- listener for updates
-
listenForDirectUpdates
Description copied from interface:DynamicTableSubscribe for updates to this table. Direct listeners are invoked immediately when changes are published, rather than via a LiveTableMonitor notification queue.- Specified by:
listenForDirectUpdatesin interfaceDynamicTable- Parameters:
listener- listener for updates
-
removeUpdateListener
Description copied from interface:DynamicTableUnsubscribe the supplied listener.- Specified by:
removeUpdateListenerin interfaceDynamicTable- Parameters:
listenerToRemove- listener for updates
-
removeUpdateListener
Description copied from interface:DynamicTableUnsubscribe the supplied listener.- Specified by:
removeUpdateListenerin interfaceDynamicTable- Parameters:
listenerToRemove- listener for updates
-
removeDirectUpdateListener
Description copied from interface:DynamicTableUnsubscribe the supplied listener.- Specified by:
removeDirectUpdateListenerin interfaceDynamicTable- Parameters:
listenerToRemove- listener for updates
-
notifyListenersOnError
public final void notifyListenersOnError(Throwable e, @Nullable UpdatePerformanceTracker.Entry sourceEntry) Description copied from interface:DynamicTableInitiate failure delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.- Specified by:
notifyListenersOnErrorin interfaceDynamicTable- Parameters:
e- errorsourceEntry- performance tracking
-
isRefreshing
public final boolean isRefreshing()Description copied from interface:DynamicNodeIs the node updating?- Specified by:
isRefreshingin interfaceDynamicNode- Returns:
- true if the node is updating; false otherwise.
-
setRefreshing
public final boolean setRefreshing(boolean refreshing) Description copied from interface:DynamicNodeChange the node's refresh mode.- Specified by:
setRefreshingin interfaceDynamicNode- Parameters:
refreshing- true to cause the node to update; false otherwise.- Returns:
- new refreshing state
-
isFailed
public boolean isFailed()- Specified by:
isFailedin interfaceDynamicTable- Returns:
- true if this table is in a failure state.
-
notifyListeners
Description copied from interface:DynamicTableInitiate update delivery to this table's listeners. Will notify direct listeners before completing, and enqueue notifications for all other listeners.- Specified by:
notifyListenersin interfaceDynamicTable- Parameters:
update- the set of table changes to propagate The caller gives this update object away; the invocation ofnotifyListenerstakes ownership, and will callreleaseon it once it is not used anymore; callers should pass aclonefor 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.DEFAULTinstance for more complex behavior.- Returns:
- The
NotificationQueueto add to.
-
getLastNotificationStep
public long getLastNotificationStep()Description copied from interface:NotificationStepSourceGet the last logical clock step on which this element dispatched a notification.- Specified by:
getLastNotificationStepin interfaceNotificationStepSource- Returns:
- The last notification step
-
setLastNotificationStep
public void setLastNotificationStep(long lastNotificationStep) Description copied from interface:NotificationStepReceiverDeliver a last notification step to this receiver.- Specified by:
setLastNotificationStepin interfaceNotificationStepReceiver- Parameters:
lastNotificationStep- The last notification step to be delivered
-
isSystemicObject
public boolean isSystemicObject()Description copied from interface:SystemicObjectReturns true if this is a systemically important object (seeSystemicObjectTracker).- Specified by:
isSystemicObjectin interfaceSystemicObject- Returns:
- true if this is a systemically important object, false otherwise.
-
markSystemic
public void markSystemic()Description copied from interface:SystemicObjectMark this object as systemically important.- Specified by:
markSystemicin interfaceSystemicObject
-
withKeys
Description copied from interface:TableSet the table's key columns. -
withUniqueKeys
Description copied from interface:TableSet the table's key columns and indicate that each key set will be unique.- Specified by:
withUniqueKeysin interfaceTable- Returns:
- The same table this method was invoked on, with the keyColumns and unique attributes set
-
restrictSortTo
Description copied from interface:TableDisallow sorting on all but the specified columns.
- Specified by:
restrictSortToin interfaceTable- Parameters:
allowedSortingColumns- The columns on which sorting is allowed.- Returns:
- The same table this was invoked on.
-
clearSortingRestrictions
Description copied from interface:TableClear 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:
clearSortingRestrictionsin interfaceTable- Returns:
- The same table this was invoked on.
-
layoutHints
- Specified by:
layoutHintsin 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:TableSets parameters for the default totals table display.- Specified by:
setTotalsTablein interfaceTable- Parameters:
builder- aTotalsTableBuilderobject- Returns:
- a table with the totals applied
-
setColumnRenderers
Description copied from interface:TableSets renderers for columns.- Specified by:
setColumnRenderersin 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:ReferenceCountedLivenessNodeAttempt 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:
destroyin classReferenceCountedLivenessNode
-
withTableDescription
- Specified by:
withTableDescriptionin interfaceTable
-
withColumnDescription
Description copied from interface:TableAdd a set of column descriptions to the table.- Specified by:
withColumnDescriptionin interfaceTable- Parameters:
descriptions- a map of Column name to Column description.- Returns:
- a copy of the table with the descriptions applied.
-