okay. given that many searches, and the complexit...
# suitescript
s
okay. given that many searches, and the complexity, it probably does make sense to move it to the reduce stage. It's usually very straightforward. If your reduce function is currently empty, just cut all of the code from map, and move it into reduce. You will need to make one change: wherever you have
JSON.parse(context.value)
replace it with
JSON.parse(context.values[0])
and it should then work just the same as the map stage, but with more governance allowance.
g
@scottvonduhn do i have to do anything in map stage?
s
no, it can be empty. the data will flow through to reduce automatically
the reason for the code change, though, is that map is designed to process a single
value
, whereas reduce is designed to process multiple
values
. Even if you only have one value (usually because you skipped the map stage), it's still wrapped in the
values
array, which is why you have to use
values[0]
to retrieve it instead.
actually, you may need to remove the map phase from the script. I usually remove it if i am not using it. I am not sure if leaving it in place but empty works or not.
g
yeah leaving it empty doesn't work, removing it seems working
s
Yeah, I realized that a few seconds after I typed it out. Sorry. Glad it's working now, though.
g
yeah but looks like reduce is bit slower than map, its taking forever to process all 3K records lol