Purpose, Argument, Streams, Usage, Examples, Related
┌─STOP─ALLEOF────────┐ >>──DEAL──┼────────────────────┼─────────────────────────────────────────────────────>< ├─STOP─┬─ALLEOF──┐ │ │ ├─ANYEOF──┼───┤ │ └─streams─┘ │ │ │ ├─SECONDARY──────────┤ │ │ │ ┌─1-*────────┐ │ └─KEY─┼────────────┼─┘ └─inputrange─┘
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 keyword 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.
**** Top of file **** Address Rxpipe 'pipe (endchar ?)', literal /a j b p l/', /* Input record data */ '| split', /* Split into individual records. */ '| j: deal secondary', /* Output stream numbers are on.. */ , /* ..the secondary input stream. */ '| specs /Stream 0:/ 1 1-* nw', /* Identify the output stream. */ '| k: faninany', /* Read from any input stream */ '| console', /* Display on the console */ '?', 'j:', '| specs /Stream 1:/ 1 1-* nw', /* Identify the output stream. */ '| k:', /* Route back to FANINANY. */ '?', 'literal /0 1 0 1 1/', /* Define output streams for DEAL */ '| split', /* Split into individual records. */ '| j:' /* Route back to DEAL on its.. */ /* ..secondary input stream. */ Exit 0 **** End of file ****
output:
Stream 0: a Stream 1: j Stream 0: b Stream 1: p Stream 1: l
salary.txt ...|...+....1....+....2....+....3....+....4.... **** Top of file **** 1 IDENT. SALARY BAND. JOB TITLE 2 ------ ---------- ------- ---------------- 3 000111 £4,000.00 L1 Associate 4 011234 £12,000.00 L2 Staff 5 096424 £8,000.00 L3 Senior Associate 6 999990 £16,000.00 L2 Advisory 7 111111 £99,000.00 L3 Senior **** End of file ****
**** Top of file **** Address Rxpipe 'pipe (endchar ?)', < salary.txt', /* Input records containing employee info. */ '| drop 2', /* Discard the two header records. */ '| f: fanout', /* Copy input records to all output streams. */ '| elastic', /* Buffer output to avoid a pipeline stall. */ '| d: deal secondary', /* Secondary input has the deal order. */ '| console', /* Stream 0 (primary) will have no records. */ '?', 'f:', /* Secondary output stream connected. */ '| specs 20.1 1', /* Level number in column 20 is stream ID. */ 'd:', /* Secondary output stream connected. */ '| > level1.txt', /* Write record to first output file. */ '?', 'd:', /* Tertiary output stream connected. */ '| > level2.txt', /* Write record to second output file. */ '?', 'd:', /* Quaternary output stream connected. */ '| > level3.txt' /* Write record to third output file. */ Exit 0 **** End of file ****
level1.txt ...|...+....1....+....2....+....3....+....4.... **** Top of file **** 1 000111 £4,000.00 L1 Associate **** End of file ****
level2.txt ...|...+....1....+....2....+....3....+....4.... **** Top of file **** 1 011234 £12,000.00 L2 Staff 2 999990 £16,000.00 L2 Advisory **** End of file ****
level3.txt ...|...+....1....+....2....+....3....+....4.... **** Top of file **** 1 096424 £8,000.00 L3 Senior Associate 2 111111 £99,000.00 L3 Senior **** End of file ****
ELASTIC, FANIN, FANINANY, FANOUT