consume

The consume operator scans all data in the input array.

Synopsis

consume( array [ ,numAttributesToScan ] )

Summary

The consume operator scans all data in the input array. The optional parameter, numAttributesToScan, determines the number of attributes to scan as a group.

  • Setting numAttributesToScan to 1 results in a vertical scan. That is, all of the values in the first attributes, then all of the values in the second, and so on. This is the default behavior. 
  • Setting numAttributesToScan to the maximum (the number of attributes in the input array) results in a horizontal scan. That is, the consume operator processes an entire chunk of results, constructing s per-cell tuple (of all attributes) for each cell in the chunk before stepping to the next chunk.
  • Setting numAttributesToScan to a value between 1 and the maximum results in a hybrid behavior. The number of attributes specified scan completely, and then the next group scans completely, and so on. For example, if your input array has 10 attributes, and you set numAttributesToScan to 2, the first two attributes scan completely, then the next two, and so on until the final two scan.

The consume operator does not return any information. It just provides accurate query timing. For example, some queries set up a delegate array, and instantly return a handle to it. The actual code that generates the data in the delegate array does not execute until the client pulls the data. If you are timing such a query, your results may be misleading. Using the consume operator ensures that all data scans, thus more accurately representing the amount of time it takes to execute your query.

Examples

Consume a query result

Given a query, use the consume operator to step through all of the cells in the result.

  1. To scan through an entire query result, use the consume operator as follows:

    AFL% consume ( list ( 'functions' ) );


    The output is:

    Query was executed successfully

Â