Class StreamletShadow<R>
- java.lang.Object
-
- org.apache.heron.streamlet.impl.StreamletBaseImpl<R>
-
- org.apache.heron.streamlet.impl.StreamletImpl<R>
-
- org.apache.heron.streamlet.impl.streamlets.StreamletShadow<R>
-
- All Implemented Interfaces:
Streamlet<R>
,StreamletBase<R>
- Direct Known Subclasses:
KVStreamletShadow
public class StreamletShadow<R> extends StreamletImpl<R>
StreamletShadow is a special kind of StreamletImpl object: - It is still an StreamletImpl therefore it supports all Streamlet functions like filter() and map(), and can be the parent object of other StreamletImpl objects. Therefore, from API point of view, it can be used in the same way as a normal StreamletImpl object. - However it is just an shadow object of a real StreamletImpl object and it doesn't represent a node in the topology DAG. Therefore it can not be a child of another StreamletImpl object. As the result, the shadow object is clonable, and it is fine to create multiple StreamletShadow objects pointing to the same StreamletImpl object and have different properties. A StreamletShadow object can be used to decorate the real Streamletimpl object. This is important for children StreamletImpl objects to consume output data from the same parent in different ways, such as selecting different stream. Usage: To create a shadow object that selecting "test" stream from an existing StreamletImpl object(stream): StreamletImpl shadow = new StreamletShadow(stream) { Override public String getStreamId() { return "test"; } }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.heron.streamlet.impl.StreamletBaseImpl
StreamletBaseImpl.StreamletNamePrefix
-
-
Field Summary
-
Fields inherited from class org.apache.heron.streamlet.impl.StreamletBaseImpl
name, nPartitions
-
-
Constructor Summary
Constructors Constructor Description StreamletShadow(StreamletImpl<R> real)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
addChild(StreamletBaseImpl<T> child)
void
build(TopologyBuilder bldr, Set<String> stageNames)
boolean
doBuild(TopologyBuilder bldr, Set<String> stageNames)
List<StreamletBaseImpl<?>>
getChildren()
Gets all the children of this streamlet.String
getName()
Gets the name of the Streamlet.int
getNumPartitions()
Gets the number of partitions of this Streamlet.StreamletImpl<R>
getReal()
String
getStreamId()
Gets the stream id of this Streamlet.StreamletShadow<R>
setName(String sName)
Sets the name of the Streamlet.StreamletShadow<R>
setNumPartitions(int numPartitions)
Sets the number of partitions of the streamlet-
Methods inherited from class org.apache.heron.streamlet.impl.StreamletImpl
applyOperator, applyOperator, clone, consume, countByKey, countByKeyAndWindow, filter, flatMap, getAvailableStreamIds, join, join, keyBy, keyBy, log, map, reduceByKey, reduceByKey, reduceByKeyAndWindow, reduceByKeyAndWindow, repartition, repartition, split, toSink, transform, union, withStream
-
Methods inherited from class org.apache.heron.streamlet.impl.StreamletBaseImpl
isBuilt, isFullyBuilt, setDefaultNameIfNone
-
-
-
-
Constructor Detail
-
StreamletShadow
public StreamletShadow(StreamletImpl<R> real)
-
-
Method Detail
-
getReal
public StreamletImpl<R> getReal()
-
getStreamId
public String getStreamId()
Gets the stream id of this Streamlet.- Specified by:
getStreamId
in interfaceStreamlet<R>
- Overrides:
getStreamId
in classStreamletImpl<R>
- Returns:
- the stream id of this Streamlet
-
setName
public StreamletShadow<R> setName(String sName)
Description copied from class:StreamletImpl
Sets the name of the Streamlet.- Specified by:
setName
in interfaceStreamlet<R>
- Specified by:
setName
in interfaceStreamletBase<R>
- Overrides:
setName
in classStreamletImpl<R>
- Parameters:
sName
- The name given by the user for this streamlet- Returns:
- Returns back the Streamlet with changed name
-
getName
public String getName()
Description copied from class:StreamletBaseImpl
Gets the name of the Streamlet.- Specified by:
getName
in interfaceStreamlet<R>
- Specified by:
getName
in interfaceStreamletBase<R>
- Overrides:
getName
in classStreamletBaseImpl<R>
- Returns:
- Returns the name of the Streamlet
-
setNumPartitions
public StreamletShadow<R> setNumPartitions(int numPartitions)
Description copied from class:StreamletImpl
Sets the number of partitions of the streamlet- Specified by:
setNumPartitions
in interfaceStreamlet<R>
- Specified by:
setNumPartitions
in interfaceStreamletBase<R>
- Overrides:
setNumPartitions
in classStreamletImpl<R>
- Parameters:
numPartitions
- The user assigned number of partitions- Returns:
- Returns back the Streamlet with changed number of partitions
-
getNumPartitions
public int getNumPartitions()
Description copied from class:StreamletBaseImpl
Gets the number of partitions of this Streamlet.- Specified by:
getNumPartitions
in interfaceStreamlet<R>
- Specified by:
getNumPartitions
in interfaceStreamletBase<R>
- Overrides:
getNumPartitions
in classStreamletBaseImpl<R>
- Returns:
- the number of partitions of this Streamlet
-
addChild
public <T> void addChild(StreamletBaseImpl<T> child)
- Overrides:
addChild
in classStreamletBaseImpl<R>
-
getChildren
public List<StreamletBaseImpl<?>> getChildren()
Gets all the children of this streamlet. Children of a streamlet are streamlets that are resulting from transformations of elements of this and potentially other streamlets.- Overrides:
getChildren
in classStreamletBaseImpl<R>
- Returns:
- The kid streamlets
-
build
public void build(TopologyBuilder bldr, Set<String> stageNames)
- Overrides:
build
in classStreamletBaseImpl<R>
-
doBuild
public boolean doBuild(TopologyBuilder bldr, Set<String> stageNames)
- Specified by:
doBuild
in classStreamletBaseImpl<R>
-
-