Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ function tileReduce(options) {

if (output) output.setMaxListeners(0);
var mapOptions = options.mapOptions || {};
var requireData = options.requireData || 'all';

for (var i = 0; i < maxWorkers; i++) {
var worker = fork(path.join(__dirname, 'worker.js'), [options.map, JSON.stringify(options.sources), JSON.stringify(mapOptions)], {silent: true});
var worker = fork(path.join(__dirname, 'worker.js'), [options.map, JSON.stringify(options.sources), JSON.stringify(mapOptions), requireData], {silent: true});
worker.stdout.pipe(binarysplit('\x1e')).pipe(output);
worker.stderr.pipe(process.stderr);
worker.on('message', handleMessage);
Expand Down
17 changes: 14 additions & 3 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var isOldNode = process.versions.node.split('.')[0] < 4;

global.mapOptions = JSON.parse(process.argv[4]);
var map = require(process.argv[2]);
var requireData = process.argv[5];

JSON.parse(process.argv[3]).forEach(function(source) {
q.defer(loadSource, source);
Expand Down Expand Up @@ -42,14 +43,24 @@ function processTile(tile, callback) {
if (err) throw err;

var data = {};
var hasData = false;
for (var i = 0; i < results.length; i++) {
data[sources[i].name] = results[i];
if (!results[i]) {
callback();
process.send({reduce: true});
return;
if (requireData === 'all') {
callback();
process.send({reduce: true});
return;
}
} else {
hasData = true;
}
}
if (requireData === 'any' && !hasData) {
callback();
process.send({reduce: true});
return;
}

var writeQueue = queue(1);

Expand Down