Permalink
Browse files

Merge pull request #13 from basho/dss-compaction-tweaks

Dss compaction tweaks
  • Loading branch information...
2 parents 0ef9fc1 + c1cf1a2 commit 46f9523cc4c16b396f290edb8f129f9ddee0acb9 @dizzyd dizzyd committed Feb 6, 2012
Showing with 43 additions and 12 deletions.
  1. +13 −10 c_src/build_deps.sh
  2. +27 −1 c_src/eleveldb.cc
  3. +1 −0 c_src/eleveldb.h
  4. +2 −1 rebar.config
View
@@ -1,6 +1,6 @@
#!/bin/bash
-LEVELDB_VSN="3c8be108bfb5fbd7d51f824199627e757279f79e"
+LEVELDB_VSN="14478f170bbe3d13bc0119d41b70e112b3925453" # tweaks v1
SNAPPY_VSN="1.0.4"
set -e
@@ -16,6 +16,14 @@ case "$1" in
rm -rf leveldb system snappy-$SNAPPY_VSN
;;
+ test)
+ export CFLAGS="$CFLAGS -I $BASEDIR/system/include"
+ export LDFLAGS="$LDFLAGS -L $BASEDIR/system/lib"
+ export LD_LIBRARY_PATH="$BASEDIR/system/lib:$LD_LIBRARY_PATH"
+
+ (cd leveldb && make check)
+
+ ;;
*)
if [ ! -d snappy-$SNAPPY_VSN ]; then
tar -xzf snappy-$SNAPPY_VSN.tar.gz
@@ -26,19 +34,14 @@ case "$1" in
export CFLAGS="$CFLAGS -I $BASEDIR/system/include"
export LDFLAGS="$LDFLAGS -L $BASEDIR/system/lib"
+ export LD_LIBRARY_PATH="$BASEDIR/system/lib:$LD_LIBRARY_PATH"
if [ ! -d leveldb ]; then
- tar -xjf leveldb.tar.bz2
- (cd leveldb && git checkout $VSN)
-
- for p in patches/*.patch; do
- echo "Applying $p"
- (cd leveldb && patch -p1 < ../$p)
- done
-
+ git clone git://github.com/basho/leveldb
+ (cd leveldb && git checkout $LEVELDB_VSN)
fi
- (cd leveldb && make)
+ (cd leveldb && make all)
;;
esac
View
@@ -79,6 +79,7 @@ static ERL_NIF_TERM ATOM_PARANOID_CHECKS;
static ERL_NIF_TERM ATOM_ERROR_DB_DESTROY;
static ERL_NIF_TERM ATOM_KEYS_ONLY;
static ERL_NIF_TERM ATOM_COMPRESSION;
+static ERL_NIF_TERM ATOM_ERROR_DB_REPAIR;
static ErlNifFunc nif_funcs[] =
{
@@ -91,7 +92,7 @@ static ErlNifFunc nif_funcs[] =
{"iterator_close", 1, eleveldb_iterator_close},
{"status", 2, eleveldb_status},
{"destroy", 2, eleveldb_destroy},
- /*{"repair", 2, eleveldb_repair} */
+ {"repair", 2, eleveldb_repair},
{"is_empty", 1, eleveldb_is_empty},
};
@@ -539,6 +540,30 @@ ERL_NIF_TERM eleveldb_status(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]
}
}
+ERL_NIF_TERM eleveldb_repair(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
+{
+ char name[4096];
+ if (enif_get_string(env, argv[0], name, sizeof(name), ERL_NIF_LATIN1))
+ {
+ // Parse out the options
+ leveldb::Options opts;
+
+ leveldb::Status status = leveldb::RepairDB(name, opts);
+ if (!status.ok())
+ {
+ return error_tuple(env, ATOM_ERROR_DB_REPAIR, status);
+ }
+ else
+ {
+ return ATOM_OK;
+ }
+ }
+ else
+ {
+ return enif_make_badarg(env);
+ }
+}
+
ERL_NIF_TERM eleveldb_destroy(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
char name[4096];
@@ -658,6 +683,7 @@ static int on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
ATOM(ATOM_CACHE_SIZE, "cache_size");
ATOM(ATOM_PARANOID_CHECKS, "paranoid_checks");
ATOM(ATOM_ERROR_DB_DESTROY, "error_db_destroy");
+ ATOM(ATOM_ERROR_DB_REPAIR, "error_db_repair");
ATOM(ATOM_KEYS_ONLY, "keys_only");
ATOM(ATOM_COMPRESSION, "compression");
return 0;
View
@@ -35,6 +35,7 @@ ERL_NIF_TERM eleveldb_iterator_move(ErlNifEnv* env, int argc, const ERL_NIF_TERM
ERL_NIF_TERM eleveldb_iterator_close(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
ERL_NIF_TERM eleveldb_status(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
ERL_NIF_TERM eleveldb_destroy(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
+ERL_NIF_TERM eleveldb_repair(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
ERL_NIF_TERM eleveldb_is_empty(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
}
View
@@ -9,6 +9,7 @@
{"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/leveldb/libleveldb.a c_src/system/lib/libsnappy.a -lstdc++"}
]}.
-{pre_hooks, [{compile, "c_src/build_deps.sh"}]}.
+{pre_hooks, [{compile, "c_src/build_deps.sh"},
+ {eunit, "c_src/build_deps.sh test"}]}.
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.

0 comments on commit 46f9523

Please sign in to comment.