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.

r.table('authors').filter(lambda author:
r.table('users')['last_name'].contains(author['last_name'])).
run(conn)
David, sorry you ran into these issues. The crash is a known bug, and will be fixed in the 1.12 release (along with the new cache implementation). See https://github.com/rethinkdb/rethinkdb/issues/1389 for more details.
As to the performance you're getting, could you give some additional info so we could track this down?
- Which OS/version are you running?
- Which RethinkDB version are you running? (you can tell by running `rethinkdb --version`)
- Which client driver are you using (and which version)?
- What query do you use to get out 100 documents and how are you measuing latency?
Would really appreciate your feedback so we could fix these issues.
@coffeemug
coffeemug / gist:6444786
Created September 5, 2013 01:04
RethinkDB vs. Mongo insert test
"""Compares rethinkdb with mongo. Copied from http://pastebin.com/3PqdFTjc. Example output:
mongodb: 0.110867023468
rethink: 2.25043606758
"""
import copy
import pymongo
import rethinkdb as r
import time
@coffeemug
coffeemug / gist:6417983
Last active December 22, 2015 04:38
Importing `git log` data into RethinkDB
git log --pretty=format:"%H|%ae|%at|%s" | \
python -c " \
import rethinkdb as r; \
import sys; \
r.connect().repl(); \
r.table_create('commits').run(); \
r.table('commits').insert([dict(map(lambda x, y: [x, y], \
['id', 'email', 'date', 'subject'], \
line.split('|', 3))) \
for line in sys.stdin]) \
@coffeemug
coffeemug / gist:6168031
Last active February 3, 2022 23:16
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.
@coffeemug
coffeemug / concatMap.md
Created July 2, 2013 00:33
An example of poor API documentation

RethinkDB: The concatMap command in Javascript

Declaration

sequence.concatMap(mappingFunction) -> stream
array.concatMap(mappingFunction) -> array

Description

@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}`
@coffeemug
coffeemug / rethinkdb-getall.md
Last active March 2, 2022 07:29
Using the `getAll` command to query multiple keys in RethinkDB 1.7.

Querying by multiple keys

The previous releases of RethinkDB allowed querying indexes as follows:

// Three ways to get the user with primary key 5
r.table('users').get(5)
r.table('users').getAll(5)
r.table('users').getAll(5, {index: 'id'})
@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}