DEAL stage v1.0

Pipelines v2.0

 

Purpose, Operands, Streams used, Usage notes, Examples, See also

Home

 

Syntax

 
           _STOP_ALLEOF________
>>__DEAL__|____________________|_______________________________________________________><
          |_STOP_ _ALLEOF__ ___|
          |      |_ANYEOF__|   |
          |      |_streams_|   |
          |_SECONDARY__________|
          |      _1-*________ _|
          |_KEY_|____________|_|
                |_inputrange_|

 

Purpose

 

Use the DEAL stage to read records from its primary input stream and write records to one of its connected output streams in either sequential order; starting with the primary output stream, or some other order specified on the secondary input stream. Unless otherwise specified; DEAL writes the first input record to the connected primary output stream, the second input record to the connected secondary output stream, and so on, until the last connected output stream receives a record, and then the cycle is repeated.

 

When the SECONDARY operand is specified; DEAL sequentially processes a secondary input record and primary input record as a pair. Each secondary input stream record must contain an integer output stream identifier which will control the order in which DEAL writes output records. In this way you can choose your own output stream order rather than use the sequential default. DEAL first reads and inspects a record from the secondary input stream, and retrieves the identity of the output stream that will receive a written record. DEAL then reads a record from its primary input stream. When DEAL determines that the output stream identified in the secondary input stream is connected; DEAL writes a record from the primary input stream to the specified output stream. DEAL then consumes the records from both its primary and secondary input streams.

 

You can also write a contiguous series of primary input stream records that have matching keys to the same output stream. DEAL searches for an identified location in each input record that contains the specified key, comparing the key from one record to the next. If the key location is not specified, or it is specified but is not found, DEAL uses the entire record as the key.

 

Operands

 

    

STOP

specifies how many output streams must be at end-of-file for DEAL to stop writing output records. STOP ALLEOF is the default.

 

 

ALLEOF

specifies that input records will stop being written when DEAL determines that all output streams are no longer connected. Input records continue to be written as long as at least one output stream is connected. STOP ALLEOF is the default.

 

 

ANYEOF

specifies that input records will stop being written as soon as DEAL determines that any one of its output streams is no longer connected.

 

 

streams

is the number of streams required to reach end-of-file and become disconnected before DEAL stops writing records. Specify a decimal number of 1 or greater. Specifying 1 is the same as specifying ANYEOF.

 

    

SECONDARY

specifies that DEAL first reads and inspects a secondary input stream record containing a stream identifier before reading a primary input stream record and writing it to that identified output stream. One secondary input stream record is processed with one primary input stream record as a pair, so the order of the records on the secondary input stream controls the order in which DEAL writes primary input stream records to its output streams.

 

    

KEY

identifies the location in each input record that contains the key of each record. A contiguous group of input records with the same key are written to the same output stream. When the key changes from one input record to the next; DEAL writes the record with the changed key to the next sequential, connected output stream.

 

 

inputrange

an integer column, word or field range that defines the key.

 

Streams used

 

The following streams are used by the DEAL stage:

 

Stream

Action

 

 

Primary input stream

DEAL reads records in sequential order from its primary input stream.

Secondary input stream

DEAL reads a record from its secondary input stream, if it is connected and the SECONDARY operand is specified. The secondary input stream record is paired with a primary input stream record.

Output streams

DEAL writes each of its primary input stream records to one of its connected output streams, in either sequential order starting with the primary output stream, or the order specified on the secondary input stream.

 

Usage notes

 

     1)

DEAL does not delay the records.

 

     2)

If the DEAL stage discovers that its primary or secondary input streams are not connected, the DEAL stage ends.

 

If the SECONDARY or KEY operand is specified and the DEAL stage discovers that the output stream it needs to write the next record to is not connected; DEAL ends and any remaining input records are not fully processed.

 

If the DEAL stage discovers that the number of streams specified by the STOP operand are not connected; DEAL ends. If the number on the STOP operand is greater than the total number of output streams in the pipeline; DEAL processes as though STOP ALLEOF were specified.

 

     3)

Leaving an output stream unconnected will not cause records to be dropped; it causes DEAL to end.

 

     4)

With any operand other than the SECONDARY operand; DEAL verifies that its primary input stream is the only connected input stream and then begins execution. If the SECONDARY operand is specified; DEAL verifies that both its primary and secondary input streams are connected and then begins execution.

 

Examples

 

The following example pipeline shows how you might use DEAL to control the order in which a particular output stream receives a record. By specifying the SECONDARY operand on the DEAL stage; the pipeline writes input records to specific output streams defined by the LITERAL stage command in the third pipeline.

 

**** Top of file ****
01 Address Rxpipe
02
03 pipe (endchar ?)’,
04      literal /a j b p l/’,
05   ‘| split’,
06   ‘| j: deal secondary’,
07   ‘| specs /Stream 0:/ 1 1-* nw’,
08   ‘| console’,
09   ‘?’,
10   ‘j:’,
11   ‘| specs /Stream 1:/ 1 1-* nw’,
12   ‘| console’,
13   ‘?’,
14   ‘j:’,
15   ‘| specs /Stream 2:/ 1 1-* nw’,
16   ‘| console’,
17   ‘?’,
18   literal /0 2 0 1 1/’,
19   ‘| split’,
20   ‘| j:’
21
22 Exit 0
**** End of file ****

 

Output:

Stream 0: a

Stream 2: j

Stream 0: b

Stream 1: p

Stream 1: l

 

See also

 

Reference the following links for additional information:

 

ELASTIC, FANIN, FANINANY, FANOUT

 

History of change

 

None.