Skip to content

Instantly share code, notes, and snippets.

@danielmewes
Created February 21, 2014 00:20
Show Gist options
  • Save danielmewes/9126318 to your computer and use it in GitHub Desktop.
Save danielmewes/9126318 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Splits a given table into n evenly-spaced shards.
# call with ./split-table <tablename> <numshards>
table=$1
shards=$2
cluster="localhost:29015"
splits=`seq 0 $((16**4/$shards)) $((16**4+1)) \
| tail -n +2 \
| head -$((shards-1)) \
| xargs printf " 'S%04x'"`
echo "Splitting at these points: $splits"
conf=`eval 'cat<<EOF
split shard $table $splits
'"$conf"'
EOF'`
echo $conf | rethinkdb admin -j $cluster
@danielmewes
Copy link
Author

Based on code by @mlucy.

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