NetSuite SuiteScript Map Reduce
作者:
双流小二郎 | 来源:发表于
2019-02-11 16:05 被阅读0次
NetSuite SuiteScript Map Reduce Script Learning Note学习笔记

NetSuite+SuiteScript+Map+Reduce+Script.png
Stage 1. getInputData
- returns an object that can be transformed into a list of key/value pairs
- hard limit: 10,000 usage units, SSS_USAGE_LIMIT_EXCEEDED
- out data to map if have or to shuffle otherwise
- function: getInputData(inputContext)
Stage 2. map
- invokes one time for each key/value pair
- can write output data, in the form of new key/value pairs.
- if has reduce, output data to the shuffle and then the reduce stage
- if no reduce, sent to the summarize stage
- 1,000 usage units (the same as mass update scripts)
- function: map(mapContext)
Stage 3. shuffle
- the system sorts through any key/value pairs that were sent to the reduce stage
- to form a new set of key/value pairs, where each key is unique and each value is an array.
- function: no need write function
Stage 4. reduce
- invoked one time for each key/value pair that was provided by the shuffle stage.
- can write data as key/value pairs that are sent to the summarize stage.
- 5,000 usage units
- function: reduce(reduceContext)
Stage 5. summarize
- can retrieve and log statistics about the script's work
- can also take actions with data sent by the reduce stage
- 10,000 usage units
- function: summarize(summaryContext)
Notes
- may omit either the map or reduce function
- can also omit the summarize function
- The system supplements your logic
- The system provides robust context objects
- multiple jobs are used to execute one script
- serial stages: one getInputData job, one shuffle job and one summarize job
- parallel stages: multiple map and reduce jobs that work independently
Governance
Soft limit: yielding
- after the completion of each map or reduce function invocation
- never interrupts a function invocation
- occurring reasons
- The time limit specified by the Yield After Minutes field on the script deployment record. (3-60)
- The governance limit of 10,000 usage units per map or reduce job.
Hard Limits on Total Persisted Data
- a map/reduce script cannot exceed 200MB at any one time
- STORAGE_SIZE_EXCEEDED error
Hard Limits on Function Invocations
- getInputData: 10,000 usage units
- map: 1,000 usage units (the same as mass update scripts)
- reduce: 5,000 usage units
- summarize: 10,000 usage units
- SSS_USAGE_LIMIT_EXCEEDED error
Best Practices
Writing Efficient Map and Reduce Functions
- map better only handle one record
Passing Search Data to the getInputData Stage
- return either a search object or a saved search reference
- return the results gets greater risk for search timeout
Minimizing the Risk of Data Duplication
- Add Logic for Handling Restarts
- Leave Buffer Size Set to 1
本文标题:NetSuite SuiteScript Map Reduce
本文链接:https://www.haomeiwen.com/subject/chvqeqtx.html
网友评论