Skip to content

Instantly share code, notes, and snippets.

@wojons
Forked from danielmewes/split-table.sh
Created February 21, 2014 00:21
Show Gist options
  • Save wojons/9126332 to your computer and use it in GitHub Desktop.
Save wojons/9126332 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment