remove rocksdb_ext

no significant performance improvement
This commit is contained in:
siddontang 2014-11-05 10:47:49 +08:00
parent f0fe5cac4e
commit 7ad5e50b32
2 changed files with 0 additions and 77 deletions

View File

@ -1,20 +0,0 @@
#!/bin/bash
ROCKSDB_DIR=/usr/local/rocksdb
if test -z "$TARGET_OS"; then
TARGET_OS=`uname -s`
fi
PLATFORM_SHARED_EXT="so"
PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl,"
PLATFORM_SHARED_CFLAGS="-fPIC"
if [ "$TARGET_OS" = "Darwin" ]; then
PLATFORM_SHARED_EXT=dylib
PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name "
fi
SONAME=librocksdb_ext.$PLATFORM_SHARED_EXT
g++ $PLATFORM_SHARED_LDFLAGS$SONAME $PLATFORM_SHARED_CFLAGS -std=c++0x -L$ROCKSDB_DIR/lib -lrocksdb -I/$ROCKSDB_DIR/include rocksdb_ext.cc -o $SONAME

View File

@ -1,57 +0,0 @@
#include <rocksdb/c.h>
#include <rocksdb/db.h>
#include <string>
using namespace rocksdb;
extern "C" {
static bool SaveError(char** errptr, const Status& s) {
assert(errptr != NULL);
if (s.ok()) {
return false;
} else if (*errptr == NULL) {
*errptr = strdup(s.ToString().c_str());
} else {
free(*errptr);
*errptr = strdup(s.ToString().c_str());
}
return true;
}
void* rocksdb_get_ext(
rocksdb_t* db,
const rocksdb_readoptions_t* options,
const char* key, size_t keylen,
char** valptr,
size_t* vallen,
char** errptr) {
std::string *tmp = new(std::string);
//very tricky, maybe changed with c++ rocksdb upgrade
Status s = (*(DB**)db)->Get(*(ReadOptions*)options, Slice(key, keylen), tmp);
if (s.ok()) {
*valptr = (char*)tmp->data();
*vallen = tmp->size();
} else {
delete(tmp);
tmp = NULL;
*valptr = NULL;
*vallen = 0;
if (!s.IsNotFound()) {
SaveError(errptr, s);
}
}
return tmp;
}
void rocksdb_get_free_ext(void* context) {
std::string* s = (std::string*)context;
delete(s);
}
}