DROP stage v1.0

Pipelines v1.9

 

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

Home

 

Syntax

 
             _FIRST_    _1_______
>>__DROP__ _|_______|__|_________|_ ___________________________________________________><
          | |_LAST__|  |_numrecs_| |
          |_ _ALL_ ________________|
            |_*___|

 

Purpose

 

Use the DROP stage to discard one or more records at the beginning or end of its primary input stream. DROP selects the remaining records, copying them to its primary output stream. If its secondary output stream is connected, DROP passes any unselected records to its secondary output stream.

 

Operands

 

     

FIRST

discards records from the beginning of the input stream. This is the default.

 

    

LAST

discards records from the end of the input stream.

 

    

ALL

*

specifies that no input records are to be written to the primary output stream; all the records are to be written to the secondary output stream, if it is connected, otherwise DROP discards the records and the stage ends.

 

    

numrecs

is an unsigned integer which specifies the number of records to discard from the input stream. The default is 1. If you specify 0 for numrecs, DROP copies all of its input records to its primary output stream.

 

Streams used

 

The following streams are used by the DROP stage:

 

Stream

Action

 

 

Primary input stream

DROP reads records from its primary input stream.

Primary output stream

Any records that are not dropped are copied to the primary output stream.

Secondary output stream

DROP passes any unselected records to its secondary output stream, if it is connected.

 

Usage notes

 

     1)

DROP FIRST does not delay the records. DROP LAST delays the specified number of records.

 

     2)

DROP LAST stores the specified number of records in a buffer. For each subsequent input record (if any), DROP LAST writes the record residing longest in the buffer to the primary output stream. Otherwise, it discards the record. The input record is then stored in the buffer, queued on a first-in, first-out basis. When end-of-file is reached on the primary input stream, DROP LAST writes the specified number of records from the buffer to the secondary output stream, if it is connected, otherwise it discards the records.

 

     3)

If the DROP stage discovers that all of its output streams are not connected, the DROP stage ends.

 

     4)

DROP FIRST disconnects its secondary output stream before it writes the records to its primary output stream. DROP LAST disconnects its primary output stream before it writes the unselected records to its secondary output stream.

 

     5)

DROP verifies that its secondary input stream is not connected and then begins execution.

 

Examples

 

The following pipeline reads the file in.txt and displays on the console only record number 10.

 

pipe < in.txt
     | drop first 9
     | take 1
     | console
 

See also

 

Reference the following links for additional information:

 

FROMLABEL, HOLE, TAKE, TOLABEL