Is there an adhoc persistable type or instance of a JSMapReduceJob that the result of the JSMapReduceJob can be viewed from?


#1

How can we view results of adhoc map reduce job? We are trying to run the following

var map = function(batch, objs, job) {
var more=0 , less=0, equal=0, missing=0, idx=0;
some logic




return {‘missing’: missing, ‘more’:more, ‘less’:less, ‘equal’:equal};
};

var reduce = function(outKey, interValues, job) {
var f_missing = 0,
f_more = 0,
f_less = 0,
f_equal = 0;
interValues.forEach(function(entry){
f_missing += entry[‘missing’];
f_equal += entry[‘equal’];
f_less += entry[‘less’];
f_more += entry[‘more’];
});
return {‘missing’: f_missing, ‘more’:f_more, ‘less’:f_less, ‘equal’:f_equal};
};

var spec = JSMapReduceSpec.make({
targetType: someType,
include: “id”,
filter: “fieldA==true”, // modify filter as appropriate
limit: -1,
batchSize: 1,
map: map,
reduce: reduce
});

var status = JS.mapReduce(spec);

We are trying to see result of the job but we are trying to find out if we can save the results to an adhoc type that can be persisted? Or somehow see the results anywhere?

Thanks,
Bus/Anvesh.


#2

JSMapReduceJob jobs are saved to the JSMapReduceJob type. JSMapReduceJob.fetch() will return the final state of completed job and the current state of running jobs.


#3

The runs and results from a JsMapReduceJob are stored in the regular MapReduceRun and ReduceResult types - you can view the results there.

For instance, if you have a reference to your JsMapReduceJob in a variable named job you can do the following to view the results of the most recent run:

c3Grid(ReduceResult.fetch({
    filter: Filter.eq('run.id', job.get('run.id').at('run.id'))
}))