UNPKG

441 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var skale = require('skale-engine');
4var sc = skale.context();
5
6var data = [['hello', 1], ['world', 1], ['hello', 2], ['world', 2], ['cedric', 3]];
7
8sc.parallelize(data)
9 .partitionBy(new skale.HashPartitioner(3))
10 .collect(function(err, res) {
11 console.log(res);
12 console.assert(JSON.stringify(res) === JSON.stringify([['world', 1], ['world', 2],['hello', 1],['hello', 2],['cedric', 3]]));
13 sc.end();
14 });