Class LiveQueryTable

All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, LiveTable, NotificationQueue.Dependency, Deflatable<Table>, Table, LivenessManager, LivenessNode, LivenessReferent, LongSizedDataStructure, DynamicNode, DynamicTable, NotificationStepReceiver, NotificationStepSource, SystemicObject, Serializable

public class LiveQueryTable
extends QueryTable
implements LiveTable
A very simple QueryTable that also implements LiveTable. Additions are added with addIndex(long) or addRange(long, long); and then become effective when the refresh() or addPendingKeys() methods are called.
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • refresh

      public void refresh()
      Add the currently pending additions to the index and notify listeners. When creating a table you can not call refresh from your constructor, because the refresh sends a notification. Instead call addPendingKeys().
      Specified by:
      refresh in interface LiveTable
    • addPendingKeys

      public Index addPendingKeys()
      Add the currently pending additions to the index, without notification.
    • addIndex

      public void addIndex​(long key)
      Add a key to the index on the next refresh.
      Parameters:
      key - the key to add
    • addRange

      public void addRange​(long firstKey, long lastKey)
      Add a range of keys to the index on the next refresh.
      Parameters:
      firstKey - the first key to add, inclusive
      lastKey - the last key to add, inclusive
    • destroy

      public void destroy()

      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 class BaseTable
    • initializeTransientFieldsForLiveness

      @VisibleForTesting public final void initializeTransientFieldsForLiveness()
      Package-private for Serializable sub-classes to use in readObject only. Public to allow unit tests in another package to work around mock issues where the constructor is never invoked.
    • tryRetainReference

      public final boolean tryRetainReference()
      Description copied from interface: LivenessReferent
      If this referent is "live", behave as LivenessReferent.retainReference() and return true. Otherwise, returns false rather than throwing an exception.
      Specified by:
      tryRetainReference in interface LivenessReferent
      Returns:
      True if this referent was retained, false otherwise
    • dropReference

      public final void dropReference()
      Description copied from interface: LivenessReferent
      Drop a previously-retained reference to this referent.
      Specified by:
      dropReference in interface LivenessReferent
    • getWeakReference

      public WeakReference<? extends LivenessReferent> getWeakReference()
      Description copied from interface: LivenessReferent
      Get a WeakReference to this referent. This may be cached, or newly created.
      Specified by:
      getWeakReference in interface LivenessReferent
      Returns:
      A new or cached reference to this referent
    • tryManage

      public final boolean tryManage​(@NotNull LivenessReferent referent)
      Description copied from interface: LivenessManager
      Attempt to add the specified referent to this manager.
      Specified by:
      tryManage in interface LivenessManager
      Parameters:
      referent - The referent to add
      Returns:
      Whether the referent was in fact added
    • onReferenceCountAtZero

      protected final void onReferenceCountAtZero()
      Description copied from class: ReferenceCounted
      Callback method that will be invoked when the reference count returns to zero.
      Specified by:
      onReferenceCountAtZero in class ReferenceCounted