Package com.illumon.iris.db.util
Class ToMapListener<K,V>
java.lang.Object
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable,NotificationQueue.Dependency,LivenessManager,LivenessNode,LivenessReferent,ListenerBase,ShiftAwareListener,Serializable,Map<K,V>
Listens to a table, mapping keys to values.
When you call get, we return the value as of the start of this clock cycle.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListener
InstrumentedShiftAwareListener.NotificationNested classes/interfaces inherited from class com.illumon.iris.db.v2.InstrumentedListenerBase
InstrumentedListenerBase.ErrorNotification, InstrumentedListenerBase.NotificationBaseNested classes/interfaces inherited from interface java.util.Map
Map.Entry<K extends Object,V extends Object> Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.ShiftAwareListener
ShiftAwareListener.Update -
Field Summary
Fields inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListenerAdapter
source -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()<T> Tget(K key, ColumnSource<T> cs) <T> T<T> Tget(K key, LongFunction<T> valueProducer, LongFunction<T> prevValueProducer) Get but instead of applying the default value producer, use a custom value producer.booleanisEmpty()keySet()static <K1,V1> ToMapListener<K1, V1> make(DynamicTable source, ColumnSource<K1> keySource, ColumnSource<V1> valueSource) static ToMapListenermake(DynamicTable source, String keySourceName) static ToMapListenermake(DynamicTable source, String keySourceName, String valueSourceName) static <K1,V1> ToMapListener<K1, V1> make(DynamicTable source, LongFunction<K1> keyProducer, LongFunction<K1> prevKeyProducer, LongFunction<V1> valueProducer, LongFunction<V1> prevValueProducer) voidonUpdate(ShiftAwareListener.Update upstream) Process notification of table changes.voidintsize()values()Methods inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListenerAdapter
canExecute, destroy, onFailureInternalMethods inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListener
getNotificationMethods inherited from class com.illumon.iris.db.v2.InstrumentedListenerBase
append, getEntry, getErrorNotification, onFailure, onFailureInternalWithDependent, satisfied, setVerboseLogging, toStringMethods 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.ListenerBase
getErrorNotification, onFailureMethods 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 java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
make
-
make
-
make
public static <K1,V1> ToMapListener<K1,V1> make(DynamicTable source, ColumnSource<K1> keySource, ColumnSource<V1> valueSource) -
make
public static <K1,V1> ToMapListener<K1,V1> make(DynamicTable source, LongFunction<K1> keyProducer, LongFunction<K1> prevKeyProducer, LongFunction<V1> valueProducer, LongFunction<V1> prevValueProducer) -
onUpdate
Description copied from interface:ShiftAwareListenerProcess notification of table changes.The Listener onUpdate call executes within the
LiveTableMonitorrefresh loop. Any tables used within the listener's onUpdate call must have already been refreshed. Using the typical pattern of a Listener that is listening to a single table, withDynamicTable.listenForUpdates(Listener), this is trivially true.When the listener must reference more than just one parent, the tables (or other objects) it references, must be made a
NotificationQueue.Dependencyof the listener. For listeners that reference multiple ticking tables, a common pattern is to use aMergedListenerand collection ofListenerRecorders.- Specified by:
onUpdatein interfaceShiftAwareListener- Specified by:
onUpdatein classInstrumentedShiftAwareListenerAdapter- Parameters:
upstream- The set of upstream table updates.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
get
public <T> T get(K key, groovy.lang.Closure<T> valueProducer, groovy.lang.Closure<T> prevValueProducer) -
get
-
get
Get but instead of applying the default value producer, use a custom value producer. The intention is that you can wrap the map up with several different value producers, e.g. one for bid and another for ask.- Type Parameters:
T- the type of the value we are retrieving- Parameters:
key- the key to retrievevalueProducer- retrieve the current value out of the tableprevValueProducer- retrieve the previous value out of the table- Returns:
- the value associated with key
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-