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 type
    T - 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 a StreamCollector that will use tuples 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 by getTuples().
      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 new StreamCollector that uses a LinkedList to collect tuples.
      void tuple(T tuple)
      Add the tuple to the collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamCollector

        public StreamCollector(C tuples)
        Construct a StreamCollector that will use tuples to collect tuples seen on the stream.
    • Method Detail

      • newLinkedListCollector

        public static StreamCollector<java.util.LinkedList<Tuple>,Tuple> newLinkedListCollector()
        Create a new StreamCollector that uses a LinkedList to collect tuples. Access to the collection returned by getTuples() must be synchronized using the collection's reference.
        Returns:
        A new StreamCollector that uses a LinkedList 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 by getTuples(). 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 of tuple is synchronized using the referent to the collection passed into the constructor and returned by getTuples().
        Specified by:
        tuple in interface StreamHandler<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 the collected tuples when a punctuation mark is seen.
        Specified by:
        mark in interface StreamHandler<T>
        Parameters:
        mark - The punctuation mark.
        Throws:
        java.lang.Exception - Failure to process the punctuation mark.