Map / Reduce - possible to use global variables or not? Double checking before I get in a mess 😉 Thanks.
n
Nik
12/21/2018, 12:11 PM
No. It will be a mess
Nik
12/21/2018, 12:12 PM
Been there and what I did what set the values in the deployment parameter and then read back on each iteration. Performance wa spoor than a Scheduled because of that.
n
NElliott
12/21/2018, 12:17 PM
I don't mean a constant, I mean a global, it's something I want to update within the getInputData step but I have two functions outside that I call that make use of the global.
I guess I'll have to pass the JSON in to my function each time I call it to update it. Thanks for replying @Nik
e
eminero
12/21/2018, 1:46 PM
@NElliott From my experience it seems that Global Variables does not exist through the life cycle of the four stages in a map reduce. They are like different contexts. So if you set something in the geInput stage, then if you do not pass that value in your array/json to the map state, the value will not exist or be accessible, even if it is a Global Variable. Hopefully it makes sense.
n
NElliott
12/21/2018, 2:09 PM
Thanks for the replies guys. I'm only interested in using it in the getInputData section.
I'm off for the holiday period now but will try what I have in mind and if I remember, report back 🙂
Essentially I'm looking at this kind of structure:
var thetable = {};
function something(some,thing){
thetable[some] = thing;
}
getInputData(){
for(){
something(abc,def);
}
// use theTable to define my output to the map
}
So it's just to allow me to access the table inside the getInputData stage but be accessible to the functions I'm calling from within that stage.
NElliott
12/21/2018, 2:10 PM
(and to clarify that's not the actual functions / logic / process but just the general format)