Commit 5fcbf1d2 authored by Matthieu Dorier's avatar Matthieu Dorier

replaced size_t with hg_size_t

parent c464988e
...@@ -139,7 +139,7 @@ void BerkeleyDBDataStore::set_comparison_function(const std::string& name, compa ...@@ -139,7 +139,7 @@ void BerkeleyDBDataStore::set_comparison_function(const std::string& name, compa
_wrapper->_less = less; _wrapper->_less = less;
} }
int BerkeleyDBDataStore::put(const void* key, size_t ksize, const void* val, size_t vsize) { int BerkeleyDBDataStore::put(const void* key, hg_size_t ksize, const void* val, hg_size_t vsize) {
int status = 0; int status = 0;
bool success = false; bool success = false;
Dbt db_key((void*)key, ksize); Dbt db_key((void*)key, ksize);
...@@ -153,14 +153,14 @@ int BerkeleyDBDataStore::put(const void* key, size_t ksize, const void* val, siz ...@@ -153,14 +153,14 @@ int BerkeleyDBDataStore::put(const void* key, size_t ksize, const void* val, siz
return SDSKV_ERR_PUT; return SDSKV_ERR_PUT;
}; };
int BerkeleyDBDataStore::put_multi(size_t num_items, int BerkeleyDBDataStore::put_multi(hg_size_t num_items,
const void* const* keys, const void* const* keys,
const size_t* ksizes, const hg_size_t* ksizes,
const void* const* values, const void* const* values,
const size_t* vsizes) const hg_size_t* vsizes)
{ {
size_t sk = 0; hg_size_t sk = 0;
size_t sv = 0; hg_size_t sv = 0;
for(unsigned i = 0; i < num_items; i++) { for(unsigned i = 0; i < num_items; i++) {
sk += ksizes[i]; sk += ksizes[i];
sv += vsizes[i]+8; sv += vsizes[i]+8;
...@@ -187,7 +187,7 @@ int BerkeleyDBDataStore::put_multi(size_t num_items, ...@@ -187,7 +187,7 @@ int BerkeleyDBDataStore::put_multi(size_t num_items,
DbMultipleDataBuilder keybuilder(mkey); DbMultipleDataBuilder keybuilder(mkey);
DbMultipleDataBuilder databuilder(mdata); DbMultipleDataBuilder databuilder(mdata);
for(size_t i = 0; i < num_items; i++) { for(hg_size_t i = 0; i < num_items; i++) {
keybuilder.append((void*)keys[i], ksizes[i]); keybuilder.append((void*)keys[i], ksizes[i]);
databuilder.append((void*)values[i], vsizes[i]); databuilder.append((void*)values[i], vsizes[i]);
} }
...@@ -199,7 +199,7 @@ int BerkeleyDBDataStore::put_multi(size_t num_items, ...@@ -199,7 +199,7 @@ int BerkeleyDBDataStore::put_multi(size_t num_items,
return SDSKV_SUCCESS; return SDSKV_SUCCESS;
} }
bool BerkeleyDBDataStore::exists(const void* key, size_t size) const { bool BerkeleyDBDataStore::exists(const void* key, hg_size_t size) const {
Dbt db_key((void*)key, size); Dbt db_key((void*)key, size);
db_key.set_flags(DB_DBT_USERMEM); db_key.set_flags(DB_DBT_USERMEM);
int status = _dbm->exists(NULL, &db_key, 0); int status = _dbm->exists(NULL, &db_key, 0);
...@@ -274,7 +274,7 @@ void BerkeleyDBDataStore::set_in_memory(bool enable) { ...@@ -274,7 +274,7 @@ void BerkeleyDBDataStore::set_in_memory(bool enable) {
}; };
std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_keys( std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_keys(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const
{ {
std::vector<ds_bulk_t> keys; std::vector<ds_bulk_t> keys;
Dbc * cursorp; Dbc * cursorp;
...@@ -324,7 +324,7 @@ std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_keys( ...@@ -324,7 +324,7 @@ std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_keys(
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyvals( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyvals(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const
{ {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
Dbc * cursorp; Dbc * cursorp;
...@@ -378,7 +378,7 @@ std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyvals( ...@@ -378,7 +378,7 @@ std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyvals(
} }
std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_key_range( std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const {
std::vector<ds_bulk_t> result; std::vector<ds_bulk_t> result;
// TODO implement this function // TODO implement this function
throw SDSKV_OP_NOT_IMPL; throw SDSKV_OP_NOT_IMPL;
...@@ -386,20 +386,20 @@ std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_key_range( ...@@ -386,20 +386,20 @@ std::vector<ds_bulk_t> BerkeleyDBDataStore::vlist_key_range(
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyval_range( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> BerkeleyDBDataStore::vlist_keyval_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
// TODO implement this function // TODO implement this function
throw SDSKV_OP_NOT_IMPL; throw SDSKV_OP_NOT_IMPL;
return result; return result;
} }
int BerkeleyDBDataStore::compkeys(Db *db, const Dbt *dbt1, const Dbt *dbt2, size_t *locp) { int BerkeleyDBDataStore::compkeys(Db *db, const Dbt *dbt1, const Dbt *dbt2, hg_size_t *locp) {
DbWrapper* _wrapper = (DbWrapper*)(((char*)db) - offsetof(BerkeleyDBDataStore::DbWrapper, _db)); DbWrapper* _wrapper = (DbWrapper*)(((char*)db) - offsetof(BerkeleyDBDataStore::DbWrapper, _db));
if(_wrapper->_less) { if(_wrapper->_less) {
return (_wrapper->_less)(dbt1->get_data(), dbt1->get_size(), return (_wrapper->_less)(dbt1->get_data(), dbt1->get_size(),
dbt2->get_data(), dbt2->get_size()); dbt2->get_data(), dbt2->get_size());
} else { } else {
size_t s = dbt1->get_size() > dbt2->get_size() ? dbt2->get_size() : dbt1->get_size(); hg_size_t s = dbt1->get_size() > dbt2->get_size() ? dbt2->get_size() : dbt1->get_size();
int c = std::memcmp(dbt1->get_data(), dbt2->get_data(), s); int c = std::memcmp(dbt1->get_data(), dbt2->get_data(), s);
if(c != 0) return c; if(c != 0) return c;
if(dbt1->get_size() < dbt2->get_size()) return -1; if(dbt1->get_size() < dbt2->get_size()) return -1;
......
...@@ -22,22 +22,22 @@ class BerkeleyDBDataStore : public AbstractDataStore { ...@@ -22,22 +22,22 @@ class BerkeleyDBDataStore : public AbstractDataStore {
_db(std::forward<T>(args)...), _less(nullptr) {} _db(std::forward<T>(args)...), _less(nullptr) {}
}; };
static int compkeys(Db *db, const Dbt *dbt1, const Dbt *dbt2, size_t *locp); static int compkeys(Db *db, const Dbt *dbt1, const Dbt *dbt2, hg_size_t *locp);
public: public:
BerkeleyDBDataStore(); BerkeleyDBDataStore();
BerkeleyDBDataStore(bool eraseOnGet, bool debug); BerkeleyDBDataStore(bool eraseOnGet, bool debug);
virtual ~BerkeleyDBDataStore(); virtual ~BerkeleyDBDataStore();
virtual bool openDatabase(const std::string& db_name, const std::string& path) override; virtual bool openDatabase(const std::string& db_name, const std::string& path) override;
virtual int put(const void* key, size_t ksize, const void* value, size_t vsize) override; virtual int put(const void* key, hg_size_t ksize, const void* value, hg_size_t vsize) override;
virtual int put_multi(size_t num_items, virtual int put_multi(hg_size_t num_items,
const void* const* keys, const void* const* keys,
const size_t* ksizes, const hg_size_t* ksizes,
const void* const* values, const void* const* values,
const size_t* vsizes) override; const hg_size_t* vsizes) override;
virtual bool get(const ds_bulk_t &key, ds_bulk_t &data) override; virtual bool get(const ds_bulk_t &key, ds_bulk_t &data) override;
virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data) override; virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data) override;
virtual bool exists(const void* key, size_t ksize) const override; virtual bool exists(const void* key, hg_size_t ksize) const override;
virtual bool erase(const ds_bulk_t &key) override; virtual bool erase(const ds_bulk_t &key) override;
virtual void set_in_memory(bool enable) override; // enable/disable in-memory mode virtual void set_in_memory(bool enable) override; // enable/disable in-memory mode
virtual void set_comparison_function(const std::string& name, comparator_fn less) override; virtual void set_comparison_function(const std::string& name, comparator_fn less) override;
...@@ -50,13 +50,13 @@ class BerkeleyDBDataStore : public AbstractDataStore { ...@@ -50,13 +50,13 @@ class BerkeleyDBDataStore : public AbstractDataStore {
#endif #endif
protected: protected:
virtual std::vector<ds_bulk_t> vlist_keys( virtual std::vector<ds_bulk_t> vlist_keys(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const override; const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const override;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals( virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t &) const override; const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &) const override;
virtual std::vector<ds_bulk_t> vlist_key_range( virtual std::vector<ds_bulk_t> vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const override; const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const override;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range( 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, size_t max_keys) const override; const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys) const override;
DbEnv *_dbenv = nullptr; DbEnv *_dbenv = nullptr;
Db *_dbm = nullptr; Db *_dbm = nullptr;
DbWrapper* _wrapper = nullptr; DbWrapper* _wrapper = nullptr;
......
...@@ -15,27 +15,27 @@ ...@@ -15,27 +15,27 @@
class AbstractDataStore { class AbstractDataStore {
public: public:
typedef int (*comparator_fn)(const void*, size_t, const void*, size_t); typedef int (*comparator_fn)(const void*, hg_size_t, const void*, hg_size_t);
AbstractDataStore(); AbstractDataStore();
AbstractDataStore(bool eraseOnGet, bool debug); AbstractDataStore(bool eraseOnGet, bool debug);
virtual ~AbstractDataStore(); virtual ~AbstractDataStore();
virtual bool openDatabase(const std::string& db_name, const std::string& path)=0; virtual bool openDatabase(const std::string& db_name, const std::string& path)=0;
virtual int put(const void* kdata, size_t ksize, const void* vdata, size_t vsize)=0; virtual int put(const void* kdata, hg_size_t ksize, const void* vdata, hg_size_t vsize)=0;
virtual int put(const ds_bulk_t &key, const ds_bulk_t &data) { virtual int put(const ds_bulk_t &key, const ds_bulk_t &data) {
return put(key.data(), key.size(), data.data(), data.size()); return put(key.data(), key.size(), data.data(), data.size());
} }
virtual int put(ds_bulk_t&& key, ds_bulk_t&& data) { virtual int put(ds_bulk_t&& key, ds_bulk_t&& data) {
return put(key.data(), key.size(), data.data(), data.size()); return put(key.data(), key.size(), data.data(), data.size());
} }
virtual int put_multi(size_t num_items, virtual int put_multi(hg_size_t num_items,
const void* const* keys, const void* const* keys,
const size_t* ksizes, const hg_size_t* ksizes,
const void* const* values, const void* const* values,
const size_t* vsizes) const hg_size_t* vsizes)
{ {
int ret = 0; int ret = 0;
for(size_t i=0; i < num_items; i++) { for(hg_size_t i=0; i < num_items; i++) {
int r = put(keys[i], ksizes[i], values[i], vsizes[i]); int r = put(keys[i], ksizes[i], values[i], vsizes[i]);
ret = ret == 0 ? r : 0; ret = ret == 0 ? r : 0;
} }
...@@ -43,7 +43,7 @@ class AbstractDataStore { ...@@ -43,7 +43,7 @@ class AbstractDataStore {
} }
virtual bool get(const ds_bulk_t &key, ds_bulk_t &data)=0; virtual bool get(const ds_bulk_t &key, ds_bulk_t &data)=0;
virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data)=0; virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data)=0;
virtual bool exists(const void* key, size_t ksize) const = 0; virtual bool exists(const void* key, hg_size_t ksize) const = 0;
virtual bool exists(const ds_bulk_t &key) const { virtual bool exists(const ds_bulk_t &key) const {
return exists(key.data(), key.size()); return exists(key.data(), key.size());
} }
...@@ -70,22 +70,22 @@ class AbstractDataStore { ...@@ -70,22 +70,22 @@ class AbstractDataStore {
} }
std::vector<ds_bulk_t> list_keys( std::vector<ds_bulk_t> list_keys(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t& prefix=ds_bulk_t()) const { const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t& prefix=ds_bulk_t()) const {
return vlist_keys(start_key, count, prefix); return vlist_keys(start_key, count, prefix);
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> list_keyvals( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> list_keyvals(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t& prefix=ds_bulk_t()) const { const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t& prefix=ds_bulk_t()) const {
return vlist_keyvals(start_key, count, prefix); return vlist_keyvals(start_key, count, prefix);
} }
std::vector<ds_bulk_t> list_key_range( std::vector<ds_bulk_t> list_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys=0) const { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys=0) const {
return vlist_key_range(lower_bound, upper_bound, max_keys); return vlist_key_range(lower_bound, upper_bound, max_keys);
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> list_keyval_range( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> list_keyval_range(
const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, size_t max_keys=0) const { const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys=0) const {
return vlist_keyval_range(lower_bound, upper_bound, max_keys); return vlist_keyval_range(lower_bound, upper_bound, max_keys);
} }
...@@ -99,13 +99,13 @@ class AbstractDataStore { ...@@ -99,13 +99,13 @@ class AbstractDataStore {
bool _in_memory; bool _in_memory;
virtual std::vector<ds_bulk_t> vlist_keys( virtual std::vector<ds_bulk_t> vlist_keys(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t& prefix) const = 0; const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t& prefix) const = 0;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals( virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t& prefix) const = 0; const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t& prefix) const = 0;
virtual std::vector<ds_bulk_t> vlist_key_range( virtual std::vector<ds_bulk_t> vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const = 0; const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const = 0;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range( 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, size_t max_keys) const = 0; const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys) const = 0;
}; };
#endif // datastore_h #endif // datastore_h
...@@ -25,7 +25,7 @@ std::string LevelDBDataStore::toString(const ds_bulk_t &bulk_val) { ...@@ -25,7 +25,7 @@ std::string LevelDBDataStore::toString(const ds_bulk_t &bulk_val) {
return str_val; return str_val;
}; };
std::string LevelDBDataStore::toString(const char* buf, size_t buf_size) { std::string LevelDBDataStore::toString(const char* buf, hg_size_t buf_size) {
std::string str_val(buf, buf_size); std::string str_val(buf, buf_size);
return str_val; return str_val;
}; };
...@@ -74,7 +74,7 @@ void LevelDBDataStore::set_comparison_function(const std::string& name, comparat ...@@ -74,7 +74,7 @@ void LevelDBDataStore::set_comparison_function(const std::string& name, comparat
_less = less; _less = less;
} }
int LevelDBDataStore::put(const void* key, size_t ksize, const void* value, size_t vsize) { int LevelDBDataStore::put(const void* key, hg_size_t ksize, const void* value, hg_size_t vsize) {
leveldb::Status status; leveldb::Status status;
bool success = false; bool success = false;
...@@ -95,7 +95,7 @@ bool LevelDBDataStore::erase(const ds_bulk_t &key) { ...@@ -95,7 +95,7 @@ bool LevelDBDataStore::erase(const ds_bulk_t &key) {
return status.ok(); return status.ok();
} }
bool LevelDBDataStore::exists(const void* key, size_t ksize) const { bool LevelDBDataStore::exists(const void* key, hg_size_t ksize) const {
leveldb::Status status; leveldb::Status status;
std::string value; std::string value;
status = _dbm->Get(leveldb::ReadOptions(), leveldb::Slice((const char*)key, ksize), &value); status = _dbm->Get(leveldb::ReadOptions(), leveldb::Slice((const char*)key, ksize), &value);
...@@ -140,7 +140,7 @@ void LevelDBDataStore::set_in_memory(bool enable) ...@@ -140,7 +140,7 @@ void LevelDBDataStore::set_in_memory(bool enable)
{}; {};
std::vector<ds_bulk_t> LevelDBDataStore::vlist_keys( std::vector<ds_bulk_t> LevelDBDataStore::vlist_keys(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const
{ {
std::vector<ds_bulk_t> keys; std::vector<ds_bulk_t> keys;
...@@ -176,7 +176,7 @@ std::vector<ds_bulk_t> LevelDBDataStore::vlist_keys( ...@@ -176,7 +176,7 @@ std::vector<ds_bulk_t> LevelDBDataStore::vlist_keys(
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyvals( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyvals(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const
{ {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
...@@ -215,7 +215,7 @@ std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyvals( ...@@ -215,7 +215,7 @@ std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyvals(
} }
std::vector<ds_bulk_t> LevelDBDataStore::vlist_key_range( std::vector<ds_bulk_t> LevelDBDataStore::vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const {
std::vector<ds_bulk_t> result; std::vector<ds_bulk_t> result;
// TODO implement this function // TODO implement this function
throw SDSKV_OP_NOT_IMPL; throw SDSKV_OP_NOT_IMPL;
...@@ -223,7 +223,7 @@ std::vector<ds_bulk_t> LevelDBDataStore::vlist_key_range( ...@@ -223,7 +223,7 @@ std::vector<ds_bulk_t> LevelDBDataStore::vlist_key_range(
} }
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyval_range( std::vector<std::pair<ds_bulk_t,ds_bulk_t>> LevelDBDataStore::vlist_keyval_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const {
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
// TODO implement this function // TODO implement this function
throw SDSKV_OP_NOT_IMPL; throw SDSKV_OP_NOT_IMPL;
......
...@@ -42,10 +42,10 @@ class LevelDBDataStore : public AbstractDataStore { ...@@ -42,10 +42,10 @@ class LevelDBDataStore : public AbstractDataStore {
LevelDBDataStore(bool eraseOnGet, bool debug); LevelDBDataStore(bool eraseOnGet, bool debug);
virtual ~LevelDBDataStore(); virtual ~LevelDBDataStore();
virtual bool openDatabase(const std::string& db_name, const std::string& path) override; virtual bool openDatabase(const std::string& db_name, const std::string& path) override;
virtual int put(const void* key, size_t ksize, const void* kdata, size_t dsize) override; virtual int put(const void* key, hg_size_t ksize, const void* kdata, hg_size_t dsize) override;
virtual bool get(const ds_bulk_t &key, ds_bulk_t &data) override; virtual bool get(const ds_bulk_t &key, ds_bulk_t &data) override;
virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data) override; virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data) override;
virtual bool exists(const void* key, size_t ksize) const override; virtual bool exists(const void* key, hg_size_t ksize) const override;
virtual bool erase(const ds_bulk_t &key) override; virtual bool erase(const ds_bulk_t &key) override;
virtual void set_in_memory(bool enable) override; // not supported, a no-op virtual void set_in_memory(bool enable) override; // not supported, a no-op
virtual void set_comparison_function(const std::string& name, comparator_fn less) override; virtual void set_comparison_function(const std::string& name, comparator_fn less) override;
...@@ -58,17 +58,17 @@ class LevelDBDataStore : public AbstractDataStore { ...@@ -58,17 +58,17 @@ class LevelDBDataStore : public AbstractDataStore {
#endif #endif
protected: protected:
virtual std::vector<ds_bulk_t> vlist_keys( virtual std::vector<ds_bulk_t> vlist_keys(
const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const override; const ds_bulk_t &start, hg_size_t count, const ds_bulk_t &prefix) const override;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals( virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t &prefix) const override; const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &prefix) const override;
virtual std::vector<ds_bulk_t> vlist_key_range( virtual std::vector<ds_bulk_t> vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const override; const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const override;
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range( 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, size_t max_keys) const override; const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys) const override;
leveldb::DB *_dbm = NULL; leveldb::DB *_dbm = NULL;
private: private:
static std::string toString(const ds_bulk_t &key); static std::string toString(const ds_bulk_t &key);
static std::string toString(const char* bug, size_t buf_size); static std::string toString(const char* bug, hg_size_t buf_size);
static ds_bulk_t fromString(const std::string &keystr); static ds_bulk_t fromString(const std::string &keystr);
AbstractDataStore::comparator_fn _less; AbstractDataStore::comparator_fn _less;
LevelDBDataStoreComparator _keycmp; LevelDBDataStoreComparator _keycmp;
......
...@@ -77,7 +77,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -77,7 +77,7 @@ class MapDataStore : public AbstractDataStore {
return SDSKV_SUCCESS; return SDSKV_SUCCESS;
} }
virtual int put(const void* key, size_t ksize, const void* value, size_t vsize) override { virtual int put(const void* key, hg_size_t ksize, const void* value, hg_size_t vsize) override {
if(vsize != 0) { if(vsize != 0) {
ds_bulk_t k((const char*)key, ((const char*)key)+ksize); ds_bulk_t k((const char*)key, ((const char*)key)+ksize);
ds_bulk_t v((const char*)value, ((const char*)value)+vsize); ds_bulk_t v((const char*)value, ((const char*)value)+vsize);
...@@ -114,7 +114,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -114,7 +114,7 @@ class MapDataStore : public AbstractDataStore {
return e; return e;
} }
virtual bool exists(const void* key, size_t ksize) const override { virtual bool exists(const void* key, hg_size_t ksize) const override {
return exists(ds_bulk_t((const char*)key, ((const char*)key)+ksize)); return exists(ds_bulk_t((const char*)key, ((const char*)key)+ksize));
} }
...@@ -148,7 +148,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -148,7 +148,7 @@ class MapDataStore : public AbstractDataStore {
protected: protected:
virtual std::vector<ds_bulk_t> vlist_keys( virtual std::vector<ds_bulk_t> vlist_keys(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t &prefix) const override { const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &prefix) const override {
ABT_rwlock_rdlock(_map_lock); ABT_rwlock_rdlock(_map_lock);
std::vector<ds_bulk_t> result; std::vector<ds_bulk_t> result;
decltype(_map.begin()) it; decltype(_map.begin()) it;
...@@ -173,7 +173,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -173,7 +173,7 @@ class MapDataStore : public AbstractDataStore {
} }
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals( virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(
const ds_bulk_t &start_key, size_t count, const ds_bulk_t &prefix) const override { const ds_bulk_t &start_key, hg_size_t count, const ds_bulk_t &prefix) const override {
ABT_rwlock_rdlock(_map_lock); ABT_rwlock_rdlock(_map_lock);
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
decltype(_map.begin()) it; decltype(_map.begin()) it;
...@@ -198,7 +198,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -198,7 +198,7 @@ class MapDataStore : public AbstractDataStore {
} }
virtual std::vector<ds_bulk_t> vlist_key_range( virtual std::vector<ds_bulk_t> vlist_key_range(
const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const override { const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, hg_size_t max_keys) const override {
ABT_rwlock_rdlock(_map_lock); ABT_rwlock_rdlock(_map_lock);
std::vector<ds_bulk_t> result; std::vector<ds_bulk_t> result;
decltype(_map.begin()) it, ub; decltype(_map.begin()) it, ub;
...@@ -222,7 +222,7 @@ class MapDataStore : public AbstractDataStore { ...@@ -222,7 +222,7 @@ class MapDataStore : public AbstractDataStore {
} }
virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range( 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, size_t max_keys) const override { const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, hg_size_t max_keys) const override {
ABT_rwlock_rdlock(_map_lock); ABT_rwlock_rdlock(_map_lock);
std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result; std::vector<std::pair<ds_bulk_t,ds_bulk_t>> result;
decltype(_map.begin()) it, ub; decltype(_map.begin()) it, ub;
......
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