Module swim.dataflow
Package swim.dataflow
Class AbstractRecordStreamlet<I extends Value,O extends Value>
- java.lang.Object
-
- swim.structure.Item
-
- swim.structure.Value
-
- swim.structure.Record
-
- swim.dataflow.RecordStreamlet<I,O>
-
- swim.dataflow.AbstractRecordStreamlet<I,O>
-
- All Implemented Interfaces:
Comparable<Item>
,Iterable<Item>
,Collection<Item>
,List<Item>
,Debug
,Display
,GenericStreamlet<I,O>
,Streamlet<I,O>
,StreamletScope<O>
,Builder<Item,Record>
- Direct Known Subclasses:
DownlinkStreamlet
public abstract class AbstractRecordStreamlet<I extends Value,O extends Value> extends RecordStreamlet<I,O> implements GenericStreamlet<I,O>
-
-
Field Summary
Fields Modifier and Type Field Description protected StreamletContext
context
protected StreamletScope<? extends O>
scope
protected int
version
-
Constructor Summary
Constructors Constructor Description AbstractRecordStreamlet()
AbstractRecordStreamlet(StreamletScope<? extends O> scope)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Item item)
boolean
add(Item item)
Adds a single input value to this builder, returningtrue
if the state of the builder changed.void
bindInput(String key, Outlet<? extends I> input)
Connects theInlet
of thisStreamlet
, identified by the givenkey
, to theinput
from which theInlet
should acquire its state.<T> T
castInput(String key, Form<T> form)
<T> T
castInput(String key, Form<T> form, T orElse)
<T> T
castInput(Inlet<? extends I> inlet, Form<T> form)
<T> T
castInput(Inlet<? extends I> inlet, Form<T> form, T orElse)
void
clear()
<T> T
coerceInput(String key, Form<T> form)
<T> T
coerceInput(String key, Form<T> form, T orElse)
<T> T
coerceInput(Inlet<? extends I> inlet, Form<T> form)
<T> T
coerceInput(Inlet<? extends I> inlet, Form<T> form, T orElse)
static <I extends Value,O extends Value>
voidcompileInlets(Class<?> streamletClass, RecordStreamlet<I,O> streamlet)
boolean
containsKey(String key)
Returnstrue
if thisRecord
has aField
member with a key that is equal to the givenkey
; otherwise returnsfalse
if thisRecord
has noField
member with a key equal to the givenkey
.boolean
containsKey(Value key)
Returnstrue
if thisRecord
has aField
member with a key that is equal to the givenkey
; otherwise returnsfalse
if thisRecord
has noField
member with a key equal to the givenkey
.protected void
didInvalidate()
void
didInvalidateInlet(Inlet<? extends I> inlet)
void
didInvalidateOutlet(Outlet<? super O> outlet)
protected void
didReconcile(int version)
void
didReconcileInlet(Inlet<? extends I> inlet, int version)
void
didReconcileOutlet(Outlet<? super O> outlet, int version)
void
disconnectInputs()
Disconnects allInlet
s dominated by thisStreamlet
in the dataflow dependency graph.void
disconnectOutputs()
Disconnects allInlets
s dominated by thisStreamlet
in the dataflow graph.Item
get(int index)
Returns the member of thisRecord
at the givenindex
, if theindex
is greater than or equal to zero, and less than thelength
of thisRecord
.Value
get(String key)
Value
get(Value key)
Value
getAttr(String key)
Value
getAttr(Text key)
Field
getField(String key)
Returns the lastField
member of thisRecord
whose key is equal to the givenkey
; returnsnull
if thisRecord
has noField
member with akey
equal to the givenkey
.Field
getField(Value key)
Returns the lastField
member of thisRecord
whose key is equal to the givenkey
; returnsnull
if thisRecord
has noField
member with akey
equal to the givenkey
.<I2 extends I>
I2getInput(String key)
<I2 extends I>
I2getInput(String key, I2 orElse)
<I2 extends I>
I2getInput(Inlet<I2> inlet)
<I2 extends I>
I2getInput(Inlet<I2> inlet, I2 orElse)
Item
getItem(int index)
O
getOutput(String key)
O
getOutput(Outlet<? super O> outlet)
Value
getSlot(String key)
Value
getSlot(Value key)
protected <I2 extends I>
Inlet<I2>inlet()
Inlet<I>
inlet(String key)
Returns theInlet
to thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchInlet
.protected <I2 extends I,O2>
Inoutlet<I2,O2>inoutlet()
void
invalidate()
Marks thisStreamlet
—and all of its outlets—as having stale state.boolean
isEmpty()
Returnstrue
if thisRecord
has no members.protected void
onInvalidate()
protected void
onInvalidateOutlets()
protected void
onReconcile(int version)
protected void
onReconcileInlets(int version)
protected void
onReconcileOutlets(int version)
protected <O2 extends Value>
Outlet<O2>outlet()
Outlet<O>
outlet(String key)
Returns theOutlet
of thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchOutlet
.Value
put(String key, Value newValue)
Value
put(Value key, Value newValue)
Value
putAttr(String key, Value newValue)
Value
putAttr(Text key, Value newValue)
Value
putSlot(String key, Value newValue)
Value
putSlot(Value key, Value newValue)
void
reconcile(int version)
Reconciles the state of thisStreamlet
, if the version of thisStreamlet
's state differs from the targetversion
.Item
remove(int index)
boolean
removeKey(String key)
boolean
removeKey(Value key)
Item
setItem(int index, Item item)
Replaces the member of thisRecord
at the givenindex
with a newitem
, returning the previousItem
at the givenindex
, if theindex
is greater than or equal to zero, and less than thelength
of thisRecord
.void
setStreamletContext(StreamletContext context)
Sets the environment in which thisStreamlet
operates.void
setStreamletScope(StreamletScope<? extends O> scope)
Sets the lexically scoped parent of thisStreamlet
.int
size()
Returns the number of members contained in thisRecord
.StreamletContext
streamletContext()
Returns the environment in which thisStreamlet
operates.StreamletScope<? extends O>
streamletScope()
Returns the lexically scoped parent of thisStreamlet
.void
unbindInput(String key)
Disconnects theInlet
of thisStreamlet
, identified by the givenkey
, from itsinput
Outlet
, if connected.protected void
willInvalidate()
void
willInvalidateInlet(Inlet<? extends I> inlet)
void
willInvalidateOutlet(Outlet<? super O> outlet)
protected void
willReconcile(int version)
void
willReconcileInlet(Inlet<? extends I> inlet, int version)
void
willReconcileOutlet(Outlet<? super O> outlet, int version)
-
Methods inherited from class swim.dataflow.RecordStreamlet
compile, compileInlet, isConstant
-
Methods inherited from class swim.structure.Record
add, add, add, add, add, add, add, add, add, add, add, add, addAll, addAll, alias, appended, appended, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, attr, bind, body, branch, commit, compareTo, compareTo, concat, contains, contains, containsAll, containsValue, create, create, debug, empty, entrySet, equals, evaluate, fieldCount, fieldIterator, fieldSet, flattened, hashCode, head, header, headers, indexOf, isAliased, isArray, isMutable, isObject, item, item, item, item, item, item, item, iterator, keyIterator, keySet, lastIndexOf, length, listIterator, listIterator, of, of, of, prepended, prepended, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putAttr, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, putSlot, remove, removeAll, removed, removed, retainAll, set, setItem, setItem, setItem, setItem, setItem, setItem, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, slot, stringValue, stringValue, subList, substitute, tag, tail, target, toArray, toArray, typeOrder, unflattened, updated, updated, updatedAttr, updatedAttr, updatedSlot, updatedSlot, valueCount, valueIterator, values
-
Methods inherited from class swim.structure.Value
absent, and, and, bitwiseAnd, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseOr, bitwiseXor, bitwiseXor, booleanValue, booleanValue, builder, byteValue, byteValue, charValue, charValue, conditional, conditional, divide, divide, doubleValue, doubleValue, eq, eq, extant, floatValue, floatValue, fromObject, ge, ge, gt, gt, integerValue, integerValue, intValue, intValue, inverse, isDefined, isDistinct, key, keyEquals, lambda, le, le, longValue, longValue, lt, lt, minus, minus, modulo, modulo, ne, ne, negative, not, numberValue, numberValue, or, or, plus, plus, positive, shortValue, shortValue, times, times, toValue
-
Methods inherited from class swim.structure.Item
appended, appended, appended, appended, appended, appended, cast, cast, coerce, coerce, display, evaluate, filter, filter, globalScope, invoke, max, min, precedence, prepended, prepended, prepended, prepended, prepended, prepended, substitute, toString, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Field Detail
-
scope
protected StreamletScope<? extends O extends Value> scope
-
context
protected StreamletContext context
-
version
protected int version
-
-
Constructor Detail
-
AbstractRecordStreamlet
public AbstractRecordStreamlet(StreamletScope<? extends O> scope)
-
AbstractRecordStreamlet
public AbstractRecordStreamlet()
-
-
Method Detail
-
streamletScope
public StreamletScope<? extends O> streamletScope()
Description copied from interface:Streamlet
Returns the lexically scoped parent of thisStreamlet
. Returnsnull
if thisStreamlet
has no lexical parent.- Specified by:
streamletScope
in interfaceStreamlet<I extends Value,O extends Value>
- Specified by:
streamletScope
in interfaceStreamletScope<I extends Value>
-
setStreamletScope
public void setStreamletScope(StreamletScope<? extends O> scope)
Description copied from interface:Streamlet
Sets the lexically scoped parent of thisStreamlet
.
-
streamletContext
public StreamletContext streamletContext()
Description copied from interface:Streamlet
Returns the environment in which thisStreamlet
operates.- Specified by:
streamletContext
in interfaceStreamlet<I extends Value,O extends Value>
- Specified by:
streamletContext
in interfaceStreamletScope<I extends Value>
-
setStreamletContext
public void setStreamletContext(StreamletContext context)
Description copied from interface:Streamlet
Sets the environment in which thisStreamlet
operates.
-
isEmpty
public boolean isEmpty()
Description copied from class:Record
Returnstrue
if thisRecord
has no members.
-
size
public int size()
Description copied from class:Record
Returns the number of members contained in thisRecord
.
-
containsKey
public boolean containsKey(Value key)
Description copied from class:Record
Returnstrue
if thisRecord
has aField
member with a key that is equal to the givenkey
; otherwise returnsfalse
if thisRecord
has noField
member with a key equal to the givenkey
.- Overrides:
containsKey
in classRecord
-
containsKey
public boolean containsKey(String key)
Description copied from class:Record
Returnstrue
if thisRecord
has aField
member with a key that is equal to the givenkey
; otherwise returnsfalse
if thisRecord
has noField
member with a key equal to the givenkey
. Equivalent toRecord.containsKey(Value)
, but avoids boxing thekey
string into aText
value.- Overrides:
containsKey
in classRecord
-
get
public Value get(String key)
Description copied from class:Record
Returns the value of the lastField
member of thisRecord
whose key is equal to the givenkey
; returnsAbsent
if thisRecord
has noField
member with a key equal to the givenkey
. Equivalent toRecord.get(Value)
, but avoids boxing thekey
string into aText
value.
-
getAttr
public Value getAttr(String key)
Description copied from class:Record
Returns the value of the lastAttr
member of thisRecord
whose key is equal to the givenkey
; returnsAbsent
if thisRecord
has noAttr
member with a key equal to the givenkey
. Equivalent toRecord.getAttr(Text)
, but avoids boxing thekey
string into aText
value.
-
getSlot
public Value getSlot(String key)
Description copied from class:Record
Returns the value of the lastSlot
member of thisRecord
whose key is equal to the givenkey
; returnsAbsent
if thisRecord
has noSlot
member with a key equal to the givenkey
. Equivalent toRecord.getSlot(Value)
, but avoids boxing thekey
string into aText
value.
-
getField
public Field getField(Value key)
Description copied from class:Record
Returns the lastField
member of thisRecord
whose key is equal to the givenkey
; returnsnull
if thisRecord
has noField
member with akey
equal to the givenkey
.
-
getField
public Field getField(String key)
Description copied from class:Record
Returns the lastField
member of thisRecord
whose key is equal to the givenkey
; returnsnull
if thisRecord
has noField
member with akey
equal to the givenkey
. Equivalent toRecord.getField(Value)
, but avoids boxing thekey
string into aText
value.
-
get
public Item get(int index)
Description copied from class:Record
Returns the member of thisRecord
at the givenindex
, if theindex
is greater than or equal to zero, and less than thelength
of thisRecord
.
-
setItem
public Item setItem(int index, Item item)
Description copied from class:Record
Replaces the member of thisRecord
at the givenindex
with a newitem
, returning the previousItem
at the givenindex
, if theindex
is greater than or equal to zero, and less than thelength
of thisRecord
.
-
add
public boolean add(Item item)
Description copied from interface:Builder
Adds a single input value to this builder, returningtrue
if the state of the builder changed.
-
add
public void add(int index, Item item)
-
remove
public Item remove(int index)
-
clear
public void clear()
-
inlet
public Inlet<I> inlet(String key)
Description copied from interface:Streamlet
Returns theInlet
to thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchInlet
.
-
bindInput
public void bindInput(String key, Outlet<? extends I> input)
Description copied from interface:Streamlet
Connects theInlet
of thisStreamlet
, identified by the givenkey
, to theinput
from which theInlet
should acquire its state. Delegates toInlet.bindInput(Outlet)
on the identifiedInlet
.
-
unbindInput
public void unbindInput(String key)
Description copied from interface:Streamlet
Disconnects theInlet
of thisStreamlet
, identified by the givenkey
, from itsinput
Outlet
, if connected. Delegates toInlet.unbindInput()
on the identifiedInlet
.
-
outlet
public Outlet<O> outlet(String key)
Description copied from interface:Streamlet
Returns theOutlet
of thisStreamlet
identified by the givenkey
; returnsnull
if thisStreamlet
has no suchOutlet
.
-
invalidate
public void invalidate()
Description copied from interface:Streamlet
Marks thisStreamlet
—and all of its outlets—as having stale state. Invalidating aStreamlet
will recursively invalidate all streamlets that transitively depend on the state of thisStreamlet
. Invalidating aStreamlet
does not cause its state to be recomputed. A subsequentStreamlet.reconcile(int)
call will reconcile the state of theStreamlet
.
-
reconcile
public void reconcile(int version)
Description copied from interface:Streamlet
Reconciles the state of thisStreamlet
, if the version of thisStreamlet
's state differs from the targetversion
. To reconcile its state, theStreamlet
first invokesInlet.reconcileOutput(int)
on each of its inlets, to ensure that its input states are up-to-date. It then recomputes its own state, in an implementation defined manner. Finally, it invokesOutlet.reconcileInput(int)
on its outlets, causing all transitively dependent streamlets to reconcile their own state.
-
disconnectInputs
public void disconnectInputs()
Description copied from interface:Streamlet
Disconnects allInlet
s dominated by thisStreamlet
in the dataflow dependency graph. Used to recursively clean up chains of combinators terminating at thisStreamlet
.
-
disconnectOutputs
public void disconnectOutputs()
Description copied from interface:Streamlet
Disconnects allInlets
s dominated by thisStreamlet
in the dataflow graph. Used to recursively clean up chains of combinators originating from thisStreamlet
.
-
willInvalidateInlet
public void willInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
willInvalidateInlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
didInvalidateInlet
public void didInvalidateInlet(Inlet<? extends I> inlet)
- Specified by:
didInvalidateInlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
willReconcileInlet
public void willReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
willReconcileInlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
didReconcileInlet
public void didReconcileInlet(Inlet<? extends I> inlet, int version)
- Specified by:
didReconcileInlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
willInvalidateOutlet
public void willInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
willInvalidateOutlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
didInvalidateOutlet
public void didInvalidateOutlet(Outlet<? super O> outlet)
- Specified by:
didInvalidateOutlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
willReconcileOutlet
public void willReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
willReconcileOutlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
didReconcileOutlet
public void didReconcileOutlet(Outlet<? super O> outlet, int version)
- Specified by:
didReconcileOutlet
in interfaceGenericStreamlet<I extends Value,O extends Value>
-
willInvalidate
protected void willInvalidate()
-
onInvalidate
protected void onInvalidate()
-
onInvalidateOutlets
protected void onInvalidateOutlets()
-
didInvalidate
protected void didInvalidate()
-
willReconcile
protected void willReconcile(int version)
-
onReconcileInlets
protected void onReconcileInlets(int version)
-
onReconcile
protected void onReconcile(int version)
-
onReconcileOutlets
protected void onReconcileOutlets(int version)
-
didReconcile
protected void didReconcile(int version)
-
compileInlets
public static <I extends Value,O extends Value> void compileInlets(Class<?> streamletClass, RecordStreamlet<I,O> streamlet)
-
-