com.ibm.streams.flow.handlers
Class StreamCollector<C extends java.util.Collection<T>,T>
- java.lang.Object
-
- com.ibm.streams.flow.handlers.StreamCollector<C,T>
-
- Type Parameters:
C
- Collection typeT
- Type for the tuples on the stream
- All Implemented Interfaces:
- StreamHandler<T>
public class StreamCollector<C extends java.util.Collection<T>,T> extends java.lang.Object implements StreamHandler<T>
Collect tuples seen on a stream.
Useful for testing graphs to verify the output of an operator produced the correct tuples.- Since:
- InfoSphere® Streams Version 3.1
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.String
IBM_COPYRIGHT
-
Constructor Summary
Constructors Constructor and Description StreamCollector(C tuples)
Construct aStreamCollector
that will usetuples
to collect tuples seen on the stream.
-
Method Summary
Methods Modifier and Type Method and Description int
getTupleCount()
Get the number of tuples in the collection returned bygetTuples()
.C
getTuples()
Get the tuple collection.void
mark(StreamingData.Punctuation mark)
No action is taken with punctuation marks.static StreamCollector<java.util.LinkedList<Tuple>,Tuple>
newLinkedListCollector()
Create a newStreamCollector
that uses aLinkedList
to collect tuples.void
tuple(T tuple)
Add the tuple to the collection.
-
-
-
Field Detail
-
IBM_COPYRIGHT
public static final java.lang.String IBM_COPYRIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StreamCollector
public StreamCollector(C tuples)
Construct aStreamCollector
that will usetuples
to collect tuples seen on the stream.
-
-
Method Detail
-
newLinkedListCollector
public static StreamCollector<java.util.LinkedList<Tuple>,Tuple> newLinkedListCollector()
Create a newStreamCollector
that uses aLinkedList
to collect tuples. Access to the collection returned bygetTuples()
must be synchronized using the collection's reference.- Returns:
- A new
StreamCollector
that uses aLinkedList
to collect tuples.
-
getTuples
public C getTuples()
Get the tuple collection.- Returns:
- The tuple collection
-
getTupleCount
public int getTupleCount()
Get the number of tuples in the collection returned bygetTuples()
. Note that if tuples have been removed from or added to the collection outside of this class then the returned value does not represent the number of tuples seen on the stream.- Returns:
- Number of collected tuples.
-
tuple
public void tuple(T tuple) throws java.lang.Exception
Add the tuple to the collection. Addition oftuple
is synchronized using the referent to the collection passed into the constructor and returned bygetTuples()
.- Specified by:
tuple
in interfaceStreamHandler<T>
- Parameters:
tuple
- Tuple seen on stream- Throws:
java.lang.Exception
- Failure to process the tuple.
-
mark
public void mark(StreamingData.Punctuation mark) throws java.lang.Exception
No action is taken with punctuation marks. Sub-classes may override this method to perform specific checks of the contents of thecollected tuples
when a punctuation mark is seen.- Specified by:
mark
in interfaceStreamHandler<T>
- Parameters:
mark
- The punctuation mark.- Throws:
java.lang.Exception
- Failure to process the punctuation mark.
-
-