FANIN stage v1.0

Pipelines v2.0

 

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

Home

 

Syntax

 

>>__FANIN__ ________________ __ _____ _________________________________________________><
           | <____________  |  |_ALL_|
           |___streamnum__|_|  |_*___|

 

Purpose

 

Use the FANIN stage to combine multiple input streams into a single output stream. FANIN reads records from all specified input streams and copies the records from each input stream to its primary output stream.

 

FANIN, without operands, copies all of the records from its primary input stream to its primary output stream, then all of the records from its secondary input stream to its primary output stream, and so on, until all of its input streams have been processed. Operands can be specified with FANIN to indicate which input streams are read and the order in which they are read.

 

Operands

 

    

streamnum

is an unsigned integer which specifies a particular input stream that FANIN will read from; where 0 is the primary input stream, 1 is the secondary input stream, and so on.

 

    

ALL

*

FANIN will read from all connected input streams not already specified by the streamnum operand. For example, if the FANIN stage has 5 input streams; to instruct FANIN to read all of input stream 3, followed by all of input stream 1, and then all other connected input streams in ascending order of stream number, you would specify:

 

... | f: fanin 3 1 * | ...

 

The input streams are read in the following order: 3, 1, 0, 2, 4

 

Streams used

 

The following streams are used by the FANIN stage:

 

Stream

Action

 

 

Primary input stream

FANIN, without operands, reads all records from all of its connected input streams starting with the primary input stream and continuing with the rest of the streams in order of increasing stream number. If a streamnum or multiple streamnum operands are specified, FANIN reads the records from only those input streams, in the order that they are specified.

 

If the ALL or * operand is specified, FANIN reads input records from all connected input streams. FANIN reads all the records from one stream before it begins reading records from the next stream.

Primary output stream

FANIN copies its input records to its primary output stream in the same order it reads its input records.

 

Usage notes

 

     1)

FANIN does not delay the records.

 

     2)

If the FANIN stage discovers that its primary output stream is not connected, the FANIN stage ends.

 

     3)

FANIN can cause a set of pipelines to stall if:

 

Two or more input streams originate in the same device driver or stream n does not reach the end-of-file because a previous stage is trying to write to stream n+1. The following diagram shows how a BUFFER stage can prevent a pipeline that uses a FANIN stage from stalling. Stream numbers are shown to identify the streams used.

 

 

     4)

You can also use the FANINANY stage to prevent a stall.

 

     5)

You do not have to specify all connected input streams with FANIN. For example, if streams 0, 1, 2, 3 and 4 are connected, you can specify only streams 0, 4 and 2 as in the following FANIN stage:

 

... | f: fanin 0 4 2 | ...

 

FANIN does not read any records from streams 1 and 3. However, if you specify the ALL or * operand:

 

... | f: fanin 0 4 2 all | ...

 

all the streams will be read, in the order: 0, 4, 2, 1, 3.

 

     6)

FANIN verifies that its primary output stream is the only connected output stream and then begins execution.

 

Examples

 

Sorting a range of records

 

See also

 

Reference the following links for additional information:

 

BUFFER, ELASTIC, FANINANY, FANOUT

 

History of change

 

None.