MCPcopy Index your code
hub / github.com/microsoft/SandDance / partition

Function partition

docs/app/js/sanddance-app.js:117633–117650  ·  view source on GitHub ↗
(data, groupby, key, keyvals)

Source from the content-addressed store, hash-verified

117631 }
117632});
117633function partition(data, groupby, key, keyvals) {
117634 var get18 = (f)=>f(t), groups = [], domain = keyvals ? keyvals.slice() : [], kMap = {}, gMap = {}, gVals, gKey, group, i2, j, k2, n, t;
117635 domain.forEach((k, i)=>kMap[k] = i + 1);
117636 for(i2 = 0, n = data.length; i2 < n; ++i2){
117637 t = data[i2];
117638 k2 = key(t);
117639 j = kMap[k2] || (kMap[k2] = domain.push(k2));
117640 gKey = (gVals = groupby ? groupby.map(get18) : Empty) + "";
117641 if (!(group = gMap[gKey])) {
117642 group = gMap[gKey] = [];
117643 groups.push(group);
117644 group.values = gVals;
117645 }
117646 group[j - 1] = t;
117647 }
117648 groups.domain = domain;
117649 return groups;
117650}
117651/**
117652 * Extend input tuples with aggregate values.
117653 * Calcuates aggregate values and joins them with the input stream.

Callers 2

transformFunction · 0.70
sanddance-app.jsFile · 0.70

Calls 4

keyFunction · 0.70
fieldFunction · 0.70
positionNodeFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected