Created
February 21, 2014 00:20
-
-
Save danielmewes/9126318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on code by @mlucy.