- java.lang.Object
-
- swim.streamlet.AbstractMapInoutlet<K,VI,VO,I,O>
-
- All Implemented Interfaces:
Inlet<I>
,Inoutlet<I,O>
,MapInlet<K,VI,I>
,MapInoutlet<K,VI,VO,I,O>
,MapOutlet<K,VO,O>
,Outlet<O>
- Direct Known Subclasses:
MapFieldValuesOperator
,MemoizeMapCombinator
public abstract class AbstractMapInoutlet<K,VI,VO,I,O> extends Object implements MapInoutlet<K,VI,VO,I,O>
-
-
Constructor Summary
Constructors Constructor Description AbstractMapInoutlet()
-
Method Summary
Modifier and Type Method Description void
bindInput(MapOutlet<K,VI,? extends I> input)
void
bindInput(Outlet<? extends I> input)
Connects thisInlet
to anOutlet
from which it will acquire its state.void
bindOutput(Inlet<? super O> output)
Adds anoutput
to the set ofInlet
s that depend on the state of thisOutlet
.abstract boolean
containsKey(K key)
Returnstrue
if the current state of thisMapOutlet
contains the givenkey
; otherwise returnsfalse
.protected void
didInvalidate()
protected void
didInvalidateKey(K key, KeyEffect effect)
protected void
didReconcile(int version)
protected void
didReconcileKey(K key, KeyEffect effect, int version)
void
disconnectInputs()
Disconnects allInlet
s dominated by thisInoutlet
in the dataflow dependency graph.void
disconnectOutputs()
Disconnects allInlets
s dominated by thisInoutlet
in the dataflow graph.abstract O
get()
Returns the current state of thisOutlet
.abstract VO
get(K key)
Returns the value assocaited with the givenkey
in the current state of thisMapOutlet
, if defined; otherwise returnsnull
.MapOutlet<K,VI,? extends I>
input()
Returns theOutlet
from which thisInlet
acquires its state; returnsnull
if thisInlet
is disconnected.void
invalidate()
void
invalidateInput()
void
invalidateInputKey(K key, KeyEffect effect)
Marks thisMapOutlet
as needing aneffect
applied to a givenkey
.void
invalidateKey(K key, KeyEffect effect)
void
invalidateOutput()
Marks thisInlet
—and theStreamlet
to which thisInlet
is attached—as having stale state.void
invalidateOutputKey(K key, KeyEffect effect)
Marks thisMapInlet
as needing aneffect
applied to a givenkey
.abstract Iterator<K>
keyIterator()
Returns anIterator
over the keys in the current state of thisMapOutlet
.protected void
onInvalidate()
protected void
onInvalidateKey(K key, KeyEffect effect)
protected void
onReconcile(int version)
protected void
onReconcileKey(K key, KeyEffect effect, int version)
Outlet<VO>
outlet(K key)
Returns anOutlet
that updates when the specifiedkey
updates.Iterator<Inlet<? super O>>
outputIterator()
Returns anIterator
over the set ofInlet
s that depend on the state of thisOutlet
.void
reconcile(int version)
void
reconcileInput(int version)
Reconciles the state of thisOutlet
, if the version of thisOutlet
's state differs from the targetversion
.void
reconcileInputKey(K key, int version)
Reconciles the state of an individualkey
in thisMapOutlet
, if the version of thisMapOutlet
's state differs from the targetversion
.void
reconcileKey(K key, int version)
void
reconcileOutput(int version)
Reconciles the state of thisInlet
, if the version of thisInlet
's state differs from the targetversion
.void
reconcileOutputKey(K key, int version)
Reconciles the state of an individualkey
in thisMapInlet
, if the version of thisMapInlet
's state differs from the targetversion
.void
unbindInput()
Disconnects thisInlet
from its inputOutlet
, if connected.void
unbindOutput(Inlet<? super O> output)
Removes anoutput
from the set ofInlet
s that depend on the state of thisOutlet
.void
unbindOutputs()
Disconnects all outputs from thisOutlet
by invokingInlet.unbindInput()
on eachInelt
that depends on the state of thisOutlet
.protected void
willInvalidate()
protected void
willInvalidateKey(K key, KeyEffect effect)
protected void
willReconcile(int version)
protected void
willReconcileKey(K key, KeyEffect effect, int version)
-
-
-
Method Detail
-
containsKey
public abstract boolean containsKey(K key)
Description copied from interface:MapOutlet
Returnstrue
if the current state of thisMapOutlet
contains the givenkey
; otherwise returnsfalse
.- Specified by:
containsKey
in interfaceMapOutlet<K,VI,VO>
-
get
public abstract VO get(K key)
Description copied from interface:MapOutlet
Returns the value assocaited with the givenkey
in the current state of thisMapOutlet
, if defined; otherwise returnsnull
.
-
get
public abstract O get()
Description copied from interface:Outlet
Returns the current state of thisOutlet
.
-
keyIterator
public abstract Iterator<K> keyIterator()
Description copied from interface:MapOutlet
Returns anIterator
over the keys in the current state of thisMapOutlet
.- Specified by:
keyIterator
in interfaceMapOutlet<K,VI,VO>
-
input
public MapOutlet<K,VI,? extends I> input()
Description copied from interface:Inlet
Returns theOutlet
from which thisInlet
acquires its state; returnsnull
if thisInlet
is disconnected.
-
bindInput
public void bindInput(Outlet<? extends I> input)
Description copied from interface:Inlet
Connects thisInlet
to anOutlet
from which it will acquire its state. If thisInlet
is already connected, it will first disconnect from its existing input. Then, after updating itsinput
property, theInlet
will invokeOutlet.bindOutput(Inlet)
on its newinput
.
-
unbindInput
public void unbindInput()
Description copied from interface:Inlet
Disconnects thisInlet
from its inputOutlet
, if connected. After setting itsinput
property tonull
, theInlet
will invokeOutlet.unbindOutput(Inlet)
on its old input, if defined.- Specified by:
unbindInput
in interfaceInlet<K>
-
disconnectInputs
public void disconnectInputs()
Description copied from interface:Inoutlet
Disconnects allInlet
s dominated by thisInoutlet
in the dataflow dependency graph. Used to recursively clean up chains of combinators passing through thisInoutlet
.- Specified by:
disconnectInputs
in interfaceInlet<K>
- Specified by:
disconnectInputs
in interfaceInoutlet<K,VI>
- Specified by:
disconnectInputs
in interfaceOutlet<K>
-
outlet
public Outlet<VO> outlet(K key)
Description copied from interface:MapOutlet
Returns anOutlet
that updates when the specifiedkey
updates.
-
outputIterator
public Iterator<Inlet<? super O>> outputIterator()
Description copied from interface:Outlet
Returns anIterator
over the set ofInlet
s that depend on the state of thisOutlet
.- Specified by:
outputIterator
in interfaceOutlet<K>
-
bindOutput
public void bindOutput(Inlet<? super O> output)
Description copied from interface:Outlet
Adds anoutput
to the set ofInlet
s that depend on the state of thisOutlet
. Theoutput
will be invalidated when the state of thisOutlet
is invalidated, and updated when thisOutlet
is updated.- Specified by:
bindOutput
in interfaceOutlet<K>
-
unbindOutput
public void unbindOutput(Inlet<? super O> output)
Description copied from interface:Outlet
Removes anoutput
from the set ofInlet
s that depend on the state of thisOutlet
.- Specified by:
unbindOutput
in interfaceOutlet<K>
-
unbindOutputs
public void unbindOutputs()
Description copied from interface:Outlet
Disconnects all outputs from thisOutlet
by invokingInlet.unbindInput()
on eachInelt
that depends on the state of thisOutlet
.- Specified by:
unbindOutputs
in interfaceOutlet<K>
-
disconnectOutputs
public void disconnectOutputs()
Description copied from interface:Inoutlet
Disconnects allInlets
s dominated by thisInoutlet
in the dataflow graph. Used to recursively clean up chains of combinators passing through thisInoutlet
.- Specified by:
disconnectOutputs
in interfaceInlet<K>
- Specified by:
disconnectOutputs
in interfaceInoutlet<K,VI>
- Specified by:
disconnectOutputs
in interfaceOutlet<K>
-
invalidateOutputKey
public void invalidateOutputKey(K key, KeyEffect effect)
Description copied from interface:MapInlet
Marks thisMapInlet
as needing aneffect
applied to a givenkey
. Invalidating an individual key invalidates the entire state of theInlet
. But only the invalidated keys need to be updated in order to reconcile the overall state of theInlet
.- Specified by:
invalidateOutputKey
in interfaceMapInlet<K,VI,VO>
-
invalidateInputKey
public void invalidateInputKey(K key, KeyEffect effect)
Description copied from interface:MapOutlet
Marks thisMapOutlet
as needing aneffect
applied to a givenkey
. Invalidating an individual key invalidates the entire state of theOutlet
. But only the invalidated keys need to be updated in order to reconcile the overall state of theOutlet
.- Specified by:
invalidateInputKey
in interfaceMapOutlet<K,VI,VO>
-
invalidateOutput
public void invalidateOutput()
Description copied from interface:Inlet
Marks thisInlet
—and theStreamlet
to which thisInlet
is attached—as having stale state. Invalidating anInlet
will recursively invalidate all streamlets that transitively depend on the state of thisInlet
. Invalidating anInlet
does not cause its state to be recomputed. A subsequentInlet.reconcileOutput(int)
call will reconcile the state of theInlet
.- Specified by:
invalidateOutput
in interfaceInlet<K>
-
invalidateInput
public void invalidateInput()
Description copied from interface:Outlet
- Specified by:
invalidateInput
in interfaceOutlet<K>
-
invalidate
public void invalidate()
-
reconcileOutputKey
public void reconcileOutputKey(K key, int version)
Description copied from interface:MapInlet
Reconciles the state of an individualkey
in thisMapInlet
, if the version of thisMapInlet
's state differs from the targetversion
. To reconcile the state of a key, theMapInlet
first invokesMapOutlet.reconcileInputKey(Object, int)
on itsinput
, if its input is aMapOutlet
, or it invokesOutlet.reconcileInput(int)
, if its input is not aMapOutlet
. Then, if all invalid keys have been reconciled, theMapInlet
invokesStreamlet.reconcile(int)
on its attached streamlet.- Specified by:
reconcileOutputKey
in interfaceMapInlet<K,VI,VO>
-
reconcileInputKey
public void reconcileInputKey(K key, int version)
Description copied from interface:MapOutlet
Reconciles the state of an individualkey
in thisMapOutlet
, if the version of thisMapOutlet
's state differs from the targetversion
. To reconcile the state of a key, theMapOutlet
first invokesStreamlet.reconcile(int)
on its attached streamlets. Then, for each dependent output, it invokesMapInlet.reconcileOutputKey(Object, int)
, if the dependent output is aMapInlet
, or it invokesInlet.reconcileOutput(int)
, if the dependent output is not aMapInlet
.- Specified by:
reconcileInputKey
in interfaceMapOutlet<K,VI,VO>
-
reconcileKey
public void reconcileKey(K key, int version)
-
reconcileOutput
public void reconcileOutput(int version)
Description copied from interface:Inlet
Reconciles the state of thisInlet
, if the version of thisInlet
's state differs from the targetversion
. To reconcile its state, theInlet
first invokesOutlet.reconcileInput(int)
on itsinput
, to ensure that its input is up-to-date. It then invokesStreamlet.reconcile(int)
on theStreamlet
to which it's attached, causing theStreamlet
to reconcile its own state.- Specified by:
reconcileOutput
in interfaceInlet<K>
-
reconcileInput
public void reconcileInput(int version)
Description copied from interface:Outlet
Reconciles the state of thisOutlet
, if the version of thisOutlet
's state differs from the targetversion
. To reconcile its state, theOutlet
first invokesStreamlet.reconcile(int)
on theStreamlet
to which it's attached. It then invokesInlet.reconcileOutput(int)
on each of its dependentoutputs
.- Specified by:
reconcileInput
in interfaceOutlet<K>
-
reconcile
public void reconcile(int version)
-
willInvalidate
protected void willInvalidate()
-
onInvalidate
protected void onInvalidate()
-
didInvalidate
protected void didInvalidate()
-
willReconcile
protected void willReconcile(int version)
-
onReconcile
protected void onReconcile(int version)
-
didReconcile
protected void didReconcile(int version)
-
-