Commit d6d66bf3 authored by Matthieu Dorier's avatar Matthieu Dorier

added null data store

parent 86319984
...@@ -9,6 +9,7 @@ extern "C" { ...@@ -9,6 +9,7 @@ extern "C" {
typedef enum sdskv_db_type_t typedef enum sdskv_db_type_t
{ {
KVDB_MAP = 0, /* Datastore implementation using std::map */ KVDB_MAP = 0, /* Datastore implementation using std::map */
KVDB_NULL, /* Datastore implementation that discards evrything it receives*/
KVDB_BWTREE, /* Datastore implementation using a BwTree */ KVDB_BWTREE, /* Datastore implementation using a BwTree */
KVDB_LEVELDB, /* Datastore implementation using LevelDB */ KVDB_LEVELDB, /* Datastore implementation using LevelDB */
KVDB_BERKELEYDB,/* Datastore implementation using BerkeleyDB */ KVDB_BERKELEYDB,/* Datastore implementation using BerkeleyDB */
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "datastore.h" #include "datastore.h"
#include "map_datastore.h" #include "map_datastore.h"
#include "null_datastore.h"
#ifdef USE_BWTREE #ifdef USE_BWTREE
#include "bwtree_datastore.h" #include "bwtree_datastore.h"
...@@ -36,6 +37,17 @@ class datastore_factory { ...@@ -36,6 +37,17 @@ class datastore_factory {
} }
} }
static AbstractDataStore* open_null_datastore(
const std::string& name, const std::string& path) {
auto db = new NullDataStore();
if(db->openDatabase(name, path)) {
return db;
} else {
delete db;
return nullptr;
}
}
static AbstractDataStore* open_bwtree_datastore( static AbstractDataStore* open_bwtree_datastore(
const std::string& name, const std::string& path) { const std::string& name, const std::string& path) {
#ifdef USE_BWTREE #ifdef USE_BWTREE
...@@ -96,6 +108,8 @@ class datastore_factory { ...@@ -96,6 +108,8 @@ class datastore_factory {
#endif #endif
{ {
switch(type) { switch(type) {
case KVDB_NULL:
return open_null_datastore(name, path);
case KVDB_MAP: case KVDB_MAP:
return open_map_datastore(name, path); return open_map_datastore(name, path);
case KVDB_BWTREE: case KVDB_BWTREE:
......
#ifndef null_datastore_h
#define null_datastore_h
#include <cstring>
#include "kv-config.h"
#include "bulk.h"
#include "datastore/datastore.h"
class NullDataStore : public AbstractDataStore {
public:
NullDataStore()
: AbstractDataStore() {
}
NullDataStore(bool eraseOnGet, bool debug)
: AbstractDataStore(eraseOnGet, debug) {
}
~NullDataStore() {
}
virtual bool openDatabase(const std::string& db_name, const std::string& path) override {
_name = db_name;
_path = path;
return true;
}
virtual void sync() override {}
virtual int put(const ds_bulk_t &key, const ds_bulk_t &data) override {
return SDSKV_SUCCESS;
}
virtual int put(ds_bulk_t &&key, ds_bulk_t &&data) override {
return SDSKV_SUCCESS;
}
virtual int put(const void* key, hg_size_t ksize, const void* value, hg_size_t vsize) override {
return SDSKV_SUCCESS;
}
virtual bool get(const ds_bulk_t &key, ds_bulk_t &data) override {
return true;
}
virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t>& values) override {
return true;
}
virtual bool exists(const ds_bulk_t& key) const override {
return false;
}
virtual bool exists(const void* key, hg_size_t ksize) const override {
return false;
}
virtual bool erase(const ds_bulk_t &key) override {
return false;
}
virtual void set_in_memory(bool enable) override {
}
virtual void set_comparison_function(const std::string& name, comparator_fn less) override {
}
virtual void set_no_overwrite() override {
}
#ifdef USE_REMI
virtual remi_fileset_t create_and_populate_fileset() const override {
return REMI_FILESET_NULL;
}
#endif
protected:
virtual std::vector<ds_bulk_t> vlist_keys(
const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &prefix) const override {
std::vector<ds_bulk_t> result;
return result;
}
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(
const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &prefix) const override {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
return result;
}
virtual std::vector<ds_bulk_t> vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const override {
std::vector<ds_bulk_t> result;
return result;
}
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range(
const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys) const override {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
return result;
}
};
#endif
...@@ -716,9 +716,8 @@ int main(int argc, char** argv) { ...@@ -716,9 +716,8 @@ int main(int argc, char** argv) {
MPI_Abort(MPI_COMM_WORLD, -1); MPI_Abort(MPI_COMM_WORLD, -1);
} }
Json::Reader reader;
Json::Value config; Json::Value config;
reader.parse(config_file, config); config_file >> config;
MPI_Comm comm = MPI_COMM_WORLD; MPI_Comm comm = MPI_COMM_WORLD;
bool single_node = (size == 1); bool single_node = (size == 1);
...@@ -988,7 +987,9 @@ static void run_single_node(Json::Value& config) { ...@@ -988,7 +987,9 @@ static void run_single_node(Json::Value& config) {
margo_finalize(mid); margo_finalize(mid);
} }
static sdskv_db_type_t database_type_from_string(const std::string& type) { static sdskv_db_type_t database_type_from_string(const std::string& type) {
if(type == "map") { if(type == "null") {
return KVDB_NULL;
} else if(type == "map") {
return KVDB_MAP; return KVDB_MAP;
} else if(type == "leveldb" || type == "ldb") { } else if(type == "leveldb" || type == "ldb") {
return KVDB_LEVELDB; return KVDB_LEVELDB;
......
...@@ -43,7 +43,9 @@ static sdskv_db_type_t parse_db_type(char* db_fullname) { ...@@ -43,7 +43,9 @@ static sdskv_db_type_t parse_db_type(char* db_fullname) {
} }
*column = '\0'; *column = '\0';
char* db_type = column + 1; char* db_type = column + 1;
if(strcmp(db_type, "map") == 0) { if(strcmp(db_type, "null") == 0) {
return KVDB_NULL;
} else if(strcmp(db_type, "map") == 0) {
return KVDB_MAP; return KVDB_MAP;
} else if(strcmp(db_type, "bwt") == 0) { } else if(strcmp(db_type, "bwt") == 0) {
return KVDB_BWTREE; return KVDB_BWTREE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment