Skip to content

Instantly share code, notes, and snippets.

@philips
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philips/9097579 to your computer and use it in GitHub Desktop.
Save philips/9097579 to your computer and use it in GitHub Desktop.
This causes rethink to eat 100% cpu:
r.db('roller').table('app_event').groupedMapReduce(
r.js('(function(row) { return row.Version })'),
function(event) { return 1; },
function(acc, count) { return acc.add(count); }, 0)
RqlRuntimeError: Cannot convert javascript `undefined` to ql::datum_t. in:
r.db("roller").table("app_event").groupedMapReduce(r.js("this.Version"), function(var_12) { return 1; }, function(var_13) { return var_13.add(var_14); }, {base: 0})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
r.db('roller').table('app_event').groupedMapReduce(
r.js('this.Version'),
function(event) { return 1; },
function(acc, count) { return acc.add(count); }, 0)
@neumino
Copy link

neumino commented Feb 19, 2014

r.db('roller').table('app_event').groupedMapReduce(
    function(row) { return row.Version },           // group by Version
    function(row) { return 1 },                     // map each document to 1
    function(left, right) { return left.add(right)  // Sum
).run(...)

@neumino
Copy link

neumino commented Feb 19, 2014

By hour

r.db('roller').table('app_event').groupedMapReduce(
    function(row) { return row("date").sub(row("date").minutes().mul(60)).sub(row("date").seconds()) },           // group by Version
    function(row) { return 1 },                     // map each document to 1
    function(left, right) { return left.add(right)  // Sum
).run(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment