Reducing the size of tuples

You can use the Functor operator to extract relevant attributes from many attributes. In this example, the input for the Functor operator is transactions with many attributes; the output is transactions with only a few attributes.


This figure is described in the surrounding text.

The SPL code for the Functor operator is shown. In the output clause, you can specify the attributes that need to be mapped from the input stream to the output stream. In this example, the output clause is not required because, by default, the Functor operator maps attributes of the same name from the input stream to the output stream.

      stream<SmallDataType> SmallDataStream = Functor(BigDataStream) {
         output
            SmallDataStream: ticker = BigDataStream.ticker,
                             date   = BigDataStream.date,
                             time   = BigDataStream.time,
                             price  = BigDataStream.price;
      }

In general, the Functor operator receives tuples from an input stream and submits a tuple to the output stream after it maps the names of the attributes from the input stream to the names of the attributes in the output stream. In addition, tuples are filtered if the filter parameter is specified.

In this example, the Functor operator performs the following steps:

  1. Receives a tuple from the input stream (BigDataStream).
  2. Maps the attributes from the input stream to the output stream as specified in the output clause; then submits the tuple to the output stream (SmallDataStream).
  3. Repeats Steps 1 to 2 until all the tuples from the input stream are processed.