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.Notification
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.InstrumentedListenerBase
InstrumentedListenerBase.ErrorNotification, InstrumentedListenerBase.NotificationBase
Nested 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 TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
<T> T
get
(K key, ColumnSource<T> cs) <T> T
<T> T
get
(K key, LongFunction<T> valueProducer, LongFunction<T> prevValueProducer) Get but instead of applying the default value producer, use a custom value producer.boolean
isEmpty()
keySet()
static <K1,
V1> ToMapListener<K1, V1> make
(DynamicTable source, ColumnSource<K1> keySource, ColumnSource<V1> valueSource) static ToMapListener
make
(DynamicTable source, String keySourceName) static ToMapListener
make
(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) void
onUpdate
(ShiftAwareListener.Update upstream) Process notification of table changes.void
int
size()
values()
Methods inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListenerAdapter
canExecute, destroy, onFailureInternal
Methods inherited from class com.illumon.iris.db.v2.InstrumentedShiftAwareListener
getNotification
Methods inherited from class com.illumon.iris.db.v2.InstrumentedListenerBase
append, getEntry, getErrorNotification, onFailure, onFailureInternalWithDependent, satisfied, setVerboseLogging, toString
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.ListenerBase
getErrorNotification, onFailure
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 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:ShiftAwareListener
Process notification of table changes.The Listener onUpdate call executes within the
LiveTableMonitor
refresh 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.Dependency
of the listener. For listeners that reference multiple ticking tables, a common pattern is to use aMergedListener
and collection ofListenerRecorder
s.- Specified by:
onUpdate
in interfaceShiftAwareListener
- Specified by:
onUpdate
in classInstrumentedShiftAwareListenerAdapter
- Parameters:
upstream
- The set of upstream table updates.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in 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
-