- java.lang.Object
-
- swim.streamlet.AbstractMapInletMapOutlet<KI,KO,VI,VO,I,O>
-
- All Implemented Interfaces:
Inlet<I>
,MapInlet<KI,VI,I>
,MapInletMapOutlet<KI,KO,VI,VO,I,O>
,MapOutlet<KO,VO,O>
,Outlet<O>
- Direct Known Subclasses:
FilterFieldsOperator
public abstract class AbstractMapInletMapOutlet<KI,KO,VI,VO,I,O> extends Object implements MapInletMapOutlet<KI,KO,VI,VO,I,O>
-
-
Field Summary
Fields Modifier and Type Field Description protected MapOutlet<KI,VI,? extends I>
input
protected HashTrieMap<KO,KeyEffect>
inputEffects
protected HashTrieMap<KO,KeyOutlet<KO,VO>>
outlets
protected HashTrieMap<KI,KeyEffect>
outputEffects
protected Inlet<? super O>[]
outputs
protected int
version
-
Constructor Summary
Constructors Constructor Description AbstractMapInletMapOutlet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
bindInput(MapOutlet<KI,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(KO key)
Returnstrue
if the current state of thisMapOutlet
contains the givenkey
; otherwise returnsfalse
.void
decohere()
void
decohereInput()
Marks thisOutlet
—and alloutputs
that depend on the state of thisOutlet
—as having decoherent state.void
decohereInputKey(KO key, KeyEffect effect)
Marks thisMapOutlet
as needing aneffect
applied to a givenkey
.void
decohereOutput()
Marks thisInlet
—and theStreamlet
to which thisInlet
is attached—as having decoherent state.void
decohereOutputKey(KI key, KeyEffect effect)
Marks thisMapInlet
as needing aneffect
applied to a givenkey
.protected void
didDecohere()
protected void
didDecohereInputKey(KO key, KeyEffect effect)
protected void
didDecohereOutputKey(KI key, KeyEffect effect)
protected void
didRecohere(int version)
protected void
didRecohereInputKey(KO key, KeyEffect effect, int version)
protected void
didRecohereOutputKey(KI key, KeyEffect effect, int version)
void
disconnectInputs()
Disconnects allInlet
s dominated by thisInlet
in the dataflow dependency graph.void
disconnectOutputs()
Disconnects allOutlet
s dominated by thisInlet
in the dataflow graph.abstract O
get()
Returns the current state of thisOutlet
.abstract VO
get(KO key)
Returns the value assocaited with the givenkey
in the current state of thisMapOutlet
, if defined; otherwise returnsnull
.MapOutlet<KI,VI,? extends I>
input()
Returns theOutlet
from which thisInlet
acquires its state; returnsnull
if thisInlet
is disconnected.abstract Iterator<KO>
keyIterator()
Returns anIterator
over the keys in the current state of thisMapOutlet
.protected void
onDecohere()
protected void
onDecohereInputKey(KO key, KeyEffect effect)
protected void
onDecohereOutputKey(KI key, KeyEffect effect)
protected void
onRecohere(int version)
protected void
onRecohereInputKey(KO key, KeyEffect effect, int version)
protected void
onRecohereOutputKey(KI key, KeyEffect effect, int version)
Outlet<VO>
outlet(KO 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
recohere(int version)
void
recohereInput(int version)
Updates the state of thisOutlet
to make it consistent with the targetversion
.void
recohereInputKey(KO key, int version)
Updates the state of an individualkey
in thisMapOutlet
to make it consistent with the targetversion
.void
recohereOutput(int version)
Updates the state of thisInlet
to make it consistent with thetarget
version.void
recohereOutputKey(KI key, int version)
Updates the state of an individualkey
in thisMapInlet
to make it consistent with 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
willDecohere()
protected void
willDecohereInputKey(KO key, KeyEffect effect)
protected void
willDecohereOutputKey(KI key, KeyEffect effect)
protected void
willRecohere(int version)
protected KeyEffect
willRecohereInputKey(KO key, KeyEffect effect, int version)
protected void
willRecohereOutputKey(KI key, KeyEffect effect, int version)
-
-
-
Field Detail
-
outputEffects
protected HashTrieMap<KI,KeyEffect> outputEffects
-
inputEffects
protected HashTrieMap<KO,KeyEffect> inputEffects
-
outlets
protected HashTrieMap<KO,KeyOutlet<KO,VO>> outlets
-
version
protected int version
-
-
Method Detail
-
containsKey
public abstract boolean containsKey(KO key)
Description copied from interface:MapOutlet
Returnstrue
if the current state of thisMapOutlet
contains the givenkey
; otherwise returnsfalse
.- Specified by:
containsKey
in interfaceMapOutlet<KI,KO,VI>
-
get
public abstract VO get(KO 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<KO> keyIterator()
Description copied from interface:MapOutlet
Returns anIterator
over the keys in the current state of thisMapOutlet
.- Specified by:
keyIterator
in interfaceMapOutlet<KI,KO,VI>
-
input
public MapOutlet<KI,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<KI>
-
disconnectInputs
public void disconnectInputs()
Description copied from interface:Inlet
Disconnects allInlet
s dominated by thisInlet
in the dataflow dependency graph. Used to recursively clean up chains of combinators terminating at thisInlet
.- Specified by:
disconnectInputs
in interfaceInlet<KI>
- Specified by:
disconnectInputs
in interfaceOutlet<KI>
-
outlet
public Outlet<VO> outlet(KO 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<KI>
-
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 decohered when the state of thisOutlet
is decohered, and recohered when thisOutlet
is recohered.- Specified by:
bindOutput
in interfaceOutlet<KI>
-
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<KI>
-
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<KI>
-
disconnectOutputs
public void disconnectOutputs()
Description copied from interface:Inlet
Disconnects allOutlet
s dominated by thisInlet
in the dataflow graph. Used to recursively clean up chains of combinators passing through thisInlet
.- Specified by:
disconnectOutputs
in interfaceInlet<KI>
- Specified by:
disconnectOutputs
in interfaceOutlet<KI>
-
decohereOutputKey
public void decohereOutputKey(KI key, KeyEffect effect)
Description copied from interface:MapInlet
Marks thisMapInlet
as needing aneffect
applied to a givenkey
. Decohering an individual key decoheres the entire state of theInlet
. But only the decoherent keys need to be updated in order to recohere the overall state of theInlet
.- Specified by:
decohereOutputKey
in interfaceMapInlet<KI,KO,VI>
-
decohereInputKey
public void decohereInputKey(KO key, KeyEffect effect)
Description copied from interface:MapOutlet
Marks thisMapOutlet
as needing aneffect
applied to a givenkey
. Decohering an individual key decoheres the entire state of theOutlet
. But only the decoherent keys need to be updated in order to recohere the overall state of theOutlet
.- Specified by:
decohereInputKey
in interfaceMapOutlet<KI,KO,VI>
-
decohereOutput
public void decohereOutput()
Description copied from interface:Inlet
Marks thisInlet
—and theStreamlet
to which thisInlet
is attached—as having decoherent state. Decohering anInlet
will recursively decohere all streamlets that transitively depend on the state of thisInlet
. Decohering anInlet
does not cause its state to be recomputed. A subsequentInlet.recohereOutput(int)
call will eventually make the state of theInlet
coherent again.- Specified by:
decohereOutput
in interfaceInlet<KI>
-
decohereInput
public void decohereInput()
Description copied from interface:Outlet
Marks thisOutlet
—and alloutputs
that depend on the state of thisOutlet
—as having decoherent state.- Specified by:
decohereInput
in interfaceOutlet<KI>
-
decohere
public void decohere()
-
recohereOutputKey
public void recohereOutputKey(KI key, int version)
Description copied from interface:MapInlet
Updates the state of an individualkey
in thisMapInlet
to make it consistent with the targetversion
. TheMapInlet
only needs to update if the currentversion
differs from the targetversion
. To update the state of a key, theMapInlet
first invokesMapOutlet.recohereInputKey(Object, int)
on itsinput
, if its input is aMapOutlet
, or it invokesOutlet.recohereInput(int)
, if its input is not aMapOutlet
. Then, if all decoherent keys have been recohered, theMapInlet
invokesStreamlet.recohere(int)
on its attached streamlet.- Specified by:
recohereOutputKey
in interfaceMapInlet<KI,KO,VI>
-
recohereInputKey
public void recohereInputKey(KO key, int version)
Description copied from interface:MapOutlet
Updates the state of an individualkey
in thisMapOutlet
to make it consistent with the targetversion
. TheMapOutlet
only needs to update if its currentversion
differs from the targetversion
. To update the state of a key, theMapOutlet
first invokesStreamlet.recohere(int)
on its attached streamlets. Then, for each dependent output, it invokesMapInlet.recohereOutputKey(Object, int)
, if the dependent output is aMapInlet
, or it invokesInlet.recohereOutput(int)
, if the dependent output is not aMapInlet
.- Specified by:
recohereInputKey
in interfaceMapOutlet<KI,KO,VI>
-
recohereOutput
public void recohereOutput(int version)
Description copied from interface:Inlet
Updates the state of thisInlet
to make it consistent with thetarget
version. TheInlet
only needs to update if its currentversion
differs from the targetversion
. To update its state, theInlet
first invokesOutlet.recohereInput(int)
on itsinput
, to ensure that its input is coherent. It then invokesStreamlet.recohere(int)
on theStreamlet
to which it's attached, causing theStreamlet
to make its own state coherent again.- Specified by:
recohereOutput
in interfaceInlet<KI>
-
recohereInput
public void recohereInput(int version)
Description copied from interface:Outlet
Updates the state of thisOutlet
to make it consistent with the targetversion
. TheOutlet
only needs to update if its currentversion
differs from the targetversion
. To update its state, theOutlet
first invokesStreamlet.recohere(int)
on theStreamlet
to which it's attached. It then invokesInlet.recohereOutput(int)
on each of its dependentoutputs
.- Specified by:
recohereInput
in interfaceOutlet<KI>
-
recohere
public void recohere(int version)
-
willDecohere
protected void willDecohere()
-
onDecohere
protected void onDecohere()
-
didDecohere
protected void didDecohere()
-
willRecohereInputKey
protected KeyEffect willRecohereInputKey(KO key, KeyEffect effect, int version)
-
willRecohere
protected void willRecohere(int version)
-
onRecohere
protected void onRecohere(int version)
-
didRecohere
protected void didRecohere(int version)
-
-