Skip to content

Instantly share code, notes, and snippets.

@otobrglez
Created November 26, 2015 17:41
Show Gist options
  • Save otobrglez/cc72acb04461b35342c1 to your computer and use it in GitHub Desktop.
Save otobrglez/cc72acb04461b35342c1 to your computer and use it in GitHub Desktop.
Experimenting with map-reduce / aggregation in RethinkDB
// successful jobs grouped by type maped by req/sec
r.db('qm_production').table('jobs')
.filter({'last_event_type': 'success'})
.map(function(doc) {
return {
'ds_type': doc('ds_type'),
'last_event_type': doc('last_event_type'),
'res_sec': doc("stats_event_response_count").div(doc('stats_run_duration')),
'req_sec': doc("stats_event_request_count").div(doc('stats_run_duration'))
};
})
.group('ds_type')
.avg('res_sec')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment