Stephane
11/03/2022, 6:23 PMvalues
array in the Reduce stage of a map/reduce script built? It does not follow the order written by the Map stage? In my case the order seems to be driven by something else?scottvonduhn
11/03/2022, 8:20 PMcontext.write('fruits', 'apple');
context.write('vegetables', 'carrot');
context.write('fruits', 'banana');
context.write('nuts', 'walnut');
context.write('fruits', 'orange');
context.write('vegetables', 'turnip');
Then your reduce phase will only have three keys: 'fruits'
, 'vegetables'
, and 'nuts'
and will only run three times.
When reduce handles the 'fruits'
key, the values will be: ['apple', 'banana', 'orange']
, though it will be a JSON string that has to be parsed first.
Again, the order of the keys and values shouldn’t really matter. If order does matter, you’ll either need to sort the values appropriately, or use a scheduled script that can process everything in a particular order.scottvonduhn
11/03/2022, 8:22 PMStephane
11/03/2022, 8:41 PMStephane
11/03/2022, 8:42 PM