Skip to content

Commit

Permalink
added slicer recursing event for id_slicer resolves #611
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnoble committed Mar 26, 2018
1 parent 83e729a commit d9527a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/readers/elasticsearch_date_range/slicer.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function newSlicer(context, opConfig, executionContext, retryData, logger, clien

function makeKeyList(opConfig, data) {
const idConfig = Object.assign({}, opConfig, { starting_key_depth: 0 });
const idSlicer = require('../id_slicer')(client, executionContext, idConfig, logger, null, data);
const idSlicer = require('../id_slicer')(context, client, executionContext, idConfig, logger, null, data);
return getIdData(idSlicer);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/readers/id_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function newSlicer(context, executionContext, retryData, logger) {
const opConfig = getOpConfig(executionContext.config, 'id_reader');
const client = getClient(context, opConfig, 'elasticsearch');

return require('./id_slicer')(client, executionContext, opConfig, logger, retryData);
return require('./id_slicer')(context, client, executionContext, opConfig, logger, retryData);
}


Expand Down
5 changes: 4 additions & 1 deletion lib/readers/id_slicer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ const hexadecimal = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
const HEXADECIMAL = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];


module.exports = function (client, executionContext, opConfig, logger, retryData, range) {
module.exports = function (context, client, executionContext, opConfig, logger, retryData, range) {
const keyRange = opConfig.key_range;
const baseKeyArray = getKeyArray(opConfig);
const keyArray = opConfig.key_range ? opConfig.key_range : baseKeyArray.slice();
const startingKeyDepth = opConfig.starting_key_depth;
const elasticsearch = require('elasticsearch_api')(client, logger, opConfig);
const executionConfig = executionContext.config;
const retryError = retryModule(logger, executionConfig.max_retries);
const events = context.apis.foundation.getSystemEvents();


function getCountForKey(query) {
return elasticsearch.count(query);
Expand Down Expand Up @@ -70,6 +72,7 @@ module.exports = function (client, executionContext, opConfig, logger, retryData
return getCountForKey(query)
.then((count) => {
if (count >= opConfig.size) {
events.emit('slicer:slice:recursion');
return determineKeySlice(generator, false, rangeObj);
}

Expand Down
5 changes: 5 additions & 0 deletions spec/readers/id_slicer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ describe('id_reader', () => {
error() {},
info() {},
warn() {}
},
apis: {
foundation: {
getSystemEvents: () => eventEmitter
}
}
};

Expand Down

0 comments on commit d9527a8

Please sign in to comment.