Skip to content

Instantly share code, notes, and snippets.

@leifwalsh
Created December 10, 2013 21:01
Show Gist options
  • Save leifwalsh/7899614 to your computer and use it in GitHub Desktop.
Save leifwalsh/7899614 to your computer and use it in GitHub Desktop.
run like `./tokumx-compression-estimator.sh /data/db/test.3` and it'll print out the compression ratio you can expect by migrating from MongoDB to TokuMX
#!/bin/bash
usage() {
echo 1>&2 "usage: $0 [--bnsize=BYTES[K]] /path/to/file.N"
}
bnsize=64K
while [ $# -gt 1 ] ; do
arg=$1; shift
if [[ $arg =~ --(.*)=(.*) ]] ; then
k=${BASH_REMATCH[1]}; v=${BASH_REMATCH[2]}
eval $k=$v
else
usage; exit 1;
fi
done
case $1 in
/*) file=$1 ;;
*) file=$PWD/$1 ;;
esac
rm -rf /tmp/tokumx-compression-estimate
mkdir -p /tmp/tokumx-compression-estimate
cd /tmp/tokumx-compression-estimate
split -d -b$bnsize $file chunks.
gzip chunks.*
gzip -l chunks.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment