Skip to content

Instantly share code, notes, and snippets.

Migrating to RethinkDB 1.12

There are a number of breaking changes in RethinkDB 1.12 you should be aware of before migrating.

Data migration

First, make sure to go through the regular data migration process, since the 1.12 file format isn't compatible with file formats generated by previous versions of RethinkDB.

Then, replace group_by and grouped_map_reduce commands in your applications with the new group command.

@coffeemug
coffeemug / hn_rethink
Created October 7, 2014 19:08
Grab top stories into RethinkDB via Hacker News API
r.http("https://hacker-news.firebaseio.com/v0/topstories.json").limit(5).map(
r.http(r.add("https://hacker-news.firebaseio.com/v0/item/",
r.row.coerceTo('string'),
".json"))
);

Keybase proof

I hereby claim:

  • I am coffeemug on github.
  • I am coffeemug (https://keybase.io/coffeemug) on keybase.
  • I have a public key whose fingerprint is 5925 55F9 CC4C 2D4E E82E 97AA A33E 7D8E 5279 41E9

To claim this, I am signing this object:

@coffeemug
coffeemug / gist:2658017
Created May 11, 2012 06:55
Ubuntu 12.04 ext4 ftruncate deadlock
/* This program demonstrates a bug in the Linux kernel version 3.2.0 using the
`ext4` filesystem.
Steps to compile:
$ gcc -o demo demo.c -laio
Steps to reproduce:
1. Run `./demo FILE`, where `FILE` is the path where the program will put the
@coffeemug
coffeemug / gist:4227320
Created December 6, 2012 19:11
RethinkDB oneliner
r.table(Build.__tablename__).get(build_id).update({'result': r.table(Build.__tablename__).get(build_id)['result'].append(line)}).run()
@coffeemug
coffeemug / gist:4227353
Created December 6, 2012 19:14
RethinkDB oneliner take 2
r.table(Build.__tablename__).get(build_id).update({'result': r['result'].append(line)}).run()
@coffeemug
coffeemug / rethinkdb_president_motiff
Created May 5, 2013 04:30
RethinkDB memory utilization under President Beef's workload
--------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
--------------------------------------------------------------------------------
78 57,030,430,673 1,440,292,888 1,227,094,500 213,198,388 0
85.20% (1,227,094,500B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->26.62% (383,410,176B) 0x207EA0D: malloc_aligned(unsigned long, unsigned long) (utils.cc:234)
| ->13.94% (200,802,304B) 0x186277E: artificial_stack_t::artificial_stack_t(void (*)(), unsigned long) (context_switching.cc:37)
| | ->13.94% (200,802,304B) 0x1862F4D: coro_t::coro_t() (coroutines.cc:127)
| | ->13.94% (200,802,304B) 0x1863DAA: coro_t::get_coro() (coroutines.cc:356)
| | ->06.41% (92,274,688B) 0x18BD37A: coro_t* coro_t::get_and_init_coro<boost::_bi::bind_t<void, boost::_mfi::mf2<void, mc_inner_buf_t, bool, file_account_t*>, boost::_bi::list3<boost::_bi::value<mc_inner_buf_t*>, boost::_bi::valu
@coffeemug
coffeemug / rethinkdb-getField.md
Last active December 19, 2015 03:59
The `getField` command works on sequences in RethinkDB 1.7

The getField command now works on sequences

In the previous versions of RethinkDB you could get a subset of an object using the pluck command, and the value of a specific field using the getField command (accessible via () in Javascript and [] in Python and Ruby):

r.expr({a: 1, b: 1}).pluck('a')
// returns {a: 1}
@coffeemug
coffeemug / rethinkdb-pluck.md
Last active December 19, 2015 03:59
Plucking nested objects in RethinkDB 1.7.

Syntax for plucking nested objects

In the previous versions of RethinkDB you could use the pluck command to extract only specific attributes from an object or a sequence of objects:

r.expr({a: 1, b: {c: 1, d: 1}}).pluck('b')
// returns `b: {c: 1, d: 1}`