UNPKG

429 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var sc = require('skale-engine').context();
4
5var data = [['hello', 1], ['hello', 1], ['world', 1]];
6var nPartitions = 2;
7
8var init = 0;
9
10function reducer(a, b) {return a + b;}
11
12sc.parallelize(data, nPartitions)
13 .reduceByKey(reducer, init)
14 .collect(function(err, res) {
15 console.log(res);
16 console.assert(JSON.stringify(res) === JSON.stringify([['hello', 2], ['world', 1]]));
17 sc.end();
18 });