Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I accepted JohnnyHK answer as he answered why my code was not working from one version to another; however, I felt I should post what I modified in the code to resolve the issue.</p> <p>Map Function:</p> <pre><code>var map = function() { var key = this.tag; var fields = { tag: this.tag, networth: this.networth, land: this.land, alive: this.alive, gdi: this.gdi, M: 0, F: 0, T: 0, I: 0, C: 0, H: 0, R: 0, D: 0 }; if (this.gov == "M") fields["M"] = 1 else fields["M"] = 0 if (this.gov == "F") fields["F"] = 1 else fields["F"] = 0 if (this.gov == "T") fields["T"] = 1 else fields["T"] = 0 if (this.gov == "I") fields["I"] = 1 else fields["I"] = 0 if (this.gov == "C") fields["C"] = 1 else fields["C"] = 0 if (this.gov == "H") fields["H"] = 1 else fields["H"] = 0 if (this.gov == "R") fields["R"] = 1 else fields["R"] = 0 if (this.gov == "D") fields["D"] = 1 else fields["D"] = 0 emit(key, fields); }; </code></pre> <p>Reduce Function:</p> <pre><code>var reduce = function(k,vals) { reducedVals = { tag: k, networth: 0, land: 0, alive: 0, M: 0, F: 0, T: 0, I: 0, C: 0, H: 0, R: 0, D: 0, gdi: 0}; for (var i = 0; i &lt; vals.length; i++){ reducedVals.networth += vals[i].networth; reducedVals.land += vals[i].land; reducedVals.alive += vals[i].alive; reducedVals.gdi += vals[i].gdi; reducedVals.M += vals[i].M; reducedVals.F += vals[i].F; reducedVals.T += vals[i].T; reducedVals.I += vals[i].I; reducedVals.C += vals[i].C; reducedVals.H += vals[i].H; reducedVals.R += vals[i].R; reducedVals.D += vals[i].D; } return reducedVals; }; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload