<@U8LG4JDPY> For the `getInputData stage`, you wri...
# suitescript
k
@Kris Wood For the
getInputData stage
, you write a function that returns an object that can be transformed into a list of key/value pairs. For example, if your function returns a search of NetSuite records, the system would run the search. The key/value pairs would be the results of the search: Each key would be the internal ID of a record. Each value would be a JSON representation of the record’s field IDs and values. For the
map stage
, you can optionally write a function that the system invokes one time for each key/value pair. If appropriate, your map function can write output data, in the form of new key/value pairs. If the script also uses a reduce function, this output data is sent as input to the shuffle and then the reduce stage. Otherwise, the new key/value pairs are sent directly to the summarize stage. You do not write a function for the
shuffle stage
. In this stage, the system sorts through any key/value pairs that were sent to the reduce stage, if a reduce function is defined. These pairs may have been provided by the map function, if a map function is used. If a map function was not used, the shuffle stage uses data provided by the getInputData stage. The shuffle stage groups this data by key to form a new set of key/value pairs, where each key is unique and each value is an array. For example, suppose 100 key/value pairs were sent. Suppose that each key represents an employee, and each value represents a record that the employee created. If there were only two unique employees, and one employee created 90 records, while another employee created 10 records, then the shuffle stage would provide two key/value pairs. The keys would be the IDs of the employees. One value would be an array of 90 elements, and the other would be an array of 10 elements. For the
reduce stage
, you write a function that is invoked one time for each key/value pair that was provided by the shuffle stage. Optionally, this function can write data as key/value pairs that are sent to the summarize stage. In the
summarize stage
, your function can retrieve and log statistics about the script’s work. It can also take actions with data sent by the reduce stage.