- 浏览: 254241 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
satan_1st:
据说可以用(*this)取得当前的lambda。
Recursive Lambda in C++ -
febird:
微软不死, 天理难容
再抱怨一下Windows7 -
sunzixun:
很有见解ace也可以精简的,我们就用阉割版的
asio/ACE/apr/libevent -
febird:
hamo2008 写道用win7以来基本上没有遇到这种情况了我 ...
造 windows 的微软很脑残 -
hamo2008:
用win7以来基本上没有遇到这种情况了
造 windows 的微软很脑残
项目地址:http://code.google.com/p/febird
如前介绍,相当于 std::map<Key1,std::map<Key2,Data> >,但接口也不完全相同,这里只贴代码:
- /* vim: set tabstop=4 : */
- #ifndef __febird_bdb_kmapdset_h__
- #define __febird_bdb_kmapdset_h__
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- # pragma once
- #endif
- #include <db_cxx.h>
- #include "native_compare.h"
- #include "../io/DataIO.h"
- #include "../io/MemStream.h"
- #include "../refcount.h"
- namespace febird {
- class FEBIRD_DLL_EXPORT kmapdset_iterator_impl_base : public RefCounter
- {
- public:
- class kmapdset_base* m_owner;
- DBC* m_curp;
- int m_ret;
- DBT m_bulk;
- public:
- kmapdset_iterator_impl_base(class kmapdset_base* owner);
- void init(DB* dbp, DB_TXN* txn, const char* func);
- virtual ~kmapdset_iterator_impl_base();
- virtual void clear_vec() = 0;
- virtual void push_back(void* data, size_t size) = 0;
- virtual void load_key1(void* data, size_t size) = 0;
- virtual void save_key1(PortableDataOutput<AutoGrownMemIO>& oKey) = 0;
- bool next_key(size_t* cnt, const char* func);
- void bulk_load(DBT* tk1);
- void increment(const char* func);
- void decrement(const char* func);
- bool find_pos(const void* k1, const void* k2, bool bulk, const char* func);
- bool insert(const void* d, const char* func);
- bool update(const void* d, const char* func);
- bool replace(const void* d, const char* func);
- bool remove(const void* k2, const char* func);
- bool remove(const char* func);
- };
- class FEBIRD_DLL_EXPORT kmapdset_base
- {
- DECLARE_NONE_COPYABLE_CLASS(kmapdset_base)
- public:
- DB* m_db;
- size_t m_bulkSize;
- bt_compare_fcn_type m_bt_comp, m_dup_comp;
- kmapdset_base(DB_ENV* env, const char* dbname
- , DB_TXN* txn
- , bt_compare_fcn_type bt_comp
- , bt_compare_fcn_type dup_comp
- , const char* func
- );
- virtual ~kmapdset_base();
- virtual void save_key1(PortableDataOutput<AutoGrownMemIO>& dio, const void* key1) const = 0;
- virtual void save_key2(PortableDataOutput<AutoGrownMemIO>& dio, const void* key2) const = 0;
- virtual void save_data(PortableDataOutput<AutoGrownMemIO>& dio, const void* data) const = 0;
- virtual kmapdset_iterator_impl_base* make_iter() = 0;
- kmapdset_iterator_impl_base* begin_impl(DB_TXN* txn, const char* func);
- kmapdset_iterator_impl_base* end_impl(DB_TXN* txn, const char* func);
- kmapdset_iterator_impl_base* find_impl(const void* k1, DB_TXN* txn, u_int32_t flags, const char* func);
- kmapdset_iterator_impl_base* find_impl(const void* k1, const void* k2, DB_TXN* txn, bool bulk, const char* func);
- kmapdset_iterator_impl_base* upper_bound_impl(const void* k1, DB_TXN* txn, const char* func);
- size_t count_impl(const void* k1, DB_TXN* txn, const char* func);
- bool insert_impl(const void* k1, const void* d, DB_TXN* txn, const char* func);
- bool replace_impl(const void* k1, const void* d, DB_TXN* txn, const char* func);
- bool remove_impl(const void* k1, const void* k2, DB_TXN* txn, const char* func);
- bool remove_impl(const void* k1, DB_TXN* txn, const char* func);
- void clear_impl(DB_TXN* txn, const char* func);
- void flush_impl(const char* func);
- };
- template<class Data>
- struct kmapdset_select_key2
- {
- typedef typename Data::key_type type;
- };
- template<class Key2, class NonKeyData>
- struct kmapdset_select_key2<std::pair<Key2, NonKeyData> >
- {
- typedef Key2 type;
- };
- template<class Key1, class Key2, class Data, class Value, class Impl>
- class kmapdset_iterator :
- public std::iterator<std::bidirectional_iterator_tag, Value, ptrdiff_t, const Value*, const Value&>
- {
- boost::intrusive_ptr<Impl> m_impl;
- void copy_on_write()
- {
- if (m_impl->getRefCount() > 1)
- {
- Impl* p = new Impl(m_impl->m_owner);
- m_impl->m_ret = m_impl->m_curp->dup(m_impl->m_curp, &p->m_curp, DB_POSITION);
- FEBIRD_RT_assert(0 == m_impl->m_ret, std::runtime_error);
- m_impl.reset(p);
- }
- }
- private:
- #ifdef _MSC_VER
- //# pragma warning(disable: 4661) // declaration but not definition
- //! MSVC will warning C4661 "declaration but not definition"
- void operator++(int) { assert(0); }
- void operator--(int) { assert(0); }
- #else
- //! disable, because clone iterator will cause very much time and resource
- void operator++(int);// { assert(0); }
- void operator--(int);// { assert(0); }
- #endif
- public:
- kmapdset_iterator() {}
- explicit kmapdset_iterator(kmapdset_iterator_impl_base* impl)
- : m_impl(static_cast<Impl*>(impl))
- {
- assert(impl);
- assert(dynamic_cast<Impl*>(impl));
- }
- // bool exist() const { return DB_NOTFOUND != m_impl->m_ret && DB_KEYEMPTY != m_impl->m_ret; }
- bool exist() const { return 0 == m_impl->m_ret; }
- // increment and get key/data-cnt
- bool next_key(size_t& cnt) { return m_impl->next_key(&cnt,BOOST_CURRENT_FUNCTION); }
- bool insert(const Data& d) { return m_impl->insert(&d,BOOST_CURRENT_FUNCTION); }
- bool update(const Data& d) { return m_impl->update(&d,BOOST_CURRENT_FUNCTION); }
- bool replace(const Data& d) { return m_impl->replace(&d,BOOST_CURRENT_FUNCTION); }
- bool remove() const { return m_impl->remove(BOOST_CURRENT_FUNCTION); }
- bool remove(const Key2& k2) const { return m_impl->remove(&k2,BOOST_CURRENT_FUNCTION); }
- kmapdset_iterator& operator++()
- {
- assert(0 == m_impl->m_ret);
- copy_on_write();
- m_impl->increment(BOOST_CURRENT_FUNCTION);
- return *this;
- }
- kmapdset_iterator& operator--()
- {
- assert(0 == m_impl->m_ret);
- copy_on_write();
- m_impl->decrement(BOOST_CURRENT_FUNCTION);
- return *this;
- }
- const Value& operator*() const
- {
- assert(0 == m_impl->m_ret);
- return m_impl->m_kdv;
- }
- const Value* operator->() const
- {
- assert(0 == m_impl->m_ret);
- return &m_impl->m_kdv;
- }
- Value& get_mutable() const
- {
- assert(0 == m_impl->m_ret);
- return m_impl->m_kdv;
- }
- };
- //! @param Data Key2 is embeded in Data
- template<class Key1, class Data>
- class kmapdset : protected kmapdset_base
- {
- DECLARE_NONE_COPYABLE_CLASS(kmapdset)
- public:
- typedef Key1
- key1_t, key_type;
- typedef typename kmapdset_select_key2<Data>::type
- key2_t;
- typedef Data
- data_type, data_t;
- typedef std::pair<Key1, std::vector<Data> >
- value_type;
- typedef std::vector<Data>
- data_vec_t;
- typedef typename std::vector<Data>::const_iterator
- data_iter_t;
- protected:
- class kmapdset_iterator_impl : public kmapdset_iterator_impl_base
- {
- public:
- value_type m_kdv;
- kmapdset_iterator_impl(kmapdset_base* owner)
- : kmapdset_iterator_impl_base(owner)
- {}
- virtual void clear_vec()
- {
- m_kdv.second.resize(0);
- }
- virtual void push_back(void* data, size_t size)
- {
- Data x;
- PortableDataInput<MinMemIO> iData;
- iData.set(data);
- iData >> x;
- FEBIRD_RT_assert(iData.diff(data) == size, std::logic_error);
- m_kdv.second.push_back(x);
- }
- virtual void load_key1(void* data, size_t size)
- {
- PortableDataInput<MemIO> iKey1;
- iKey1.set(data, size);
- iKey1 >> m_kdv.first;
- FEBIRD_RT_assert(iKey1.diff(data) == size, std::logic_error);
- }
- virtual void save_key1(PortableDataOutput<AutoGrownMemIO>& oKey1)
- {
- oKey1 << m_kdv.first;
- }
- };
- //! overrides
- void save_key1(PortableDataOutput<AutoGrownMemIO>& dio, const void* key1) const { dio << *(const key1_t*)key1; }
- void save_key2(PortableDataOutput<AutoGrownMemIO>& dio, const void* key2) const { dio << *(const key2_t*)key2; }
- void save_data(PortableDataOutput<AutoGrownMemIO>& dio, const void* data) const { dio << *(const data_t*)data; }
- kmapdset_iterator_impl_base* make_iter() { return new kmapdset_iterator_impl(this); }
- public:
- typedef kmapdset_iterator<Key1, key2_t, Data, value_type, kmapdset_iterator_impl>
- iterator, const_iterator;
- kmapdset(DB_ENV* env, const char* dbname
- , DB_TXN* txn = NULL
- , bt_compare_fcn_type bt_comp = bdb_auto_bt_compare((key1_t*)(0))
- , bt_compare_fcn_type dup_comp = bdb_auto_bt_compare((key2_t*)(0))
- )
- : kmapdset_base(env, dbname, txn, bt_comp, dup_comp, BOOST_CURRENT_FUNCTION)
- {
- }
- kmapdset(DbEnv* env, const char* dbname
- , DbTxn* txn = NULL
- , bt_compare_fcn_type bt_comp = bdb_auto_bt_compare((key1_t*)(0))
- , bt_compare_fcn_type dup_comp = bdb_auto_bt_compare((key2_t*)(0))
- )
- : kmapdset_base(env->get_DB_ENV(), dbname, txn ? txn->get_DB_TXN() : NULL, bt_comp, dup_comp, BOOST_CURRENT_FUNCTION)
- {
- }
- iterator begin(DB_TXN* txn = NULL) { return iterator(begin_impl(txn, BOOST_CURRENT_FUNCTION)); }
- iterator end (DB_TXN* txn = NULL) { return iterator(end_impl (txn, BOOST_CURRENT_FUNCTION)); }
- iterator begin(DbTxn* txn) { return iterator(begin_impl(txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION)); }
- iterator end (DbTxn* txn) { return iterator(end_impl (txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION)); }
- iterator find(const Key1& k1, DB_TXN* txn = NULL)
- {
- return iterator(find_impl(&k1, txn, DB_SET|DB_MULTIPLE, BOOST_CURRENT_FUNCTION));
- }
- iterator find(const Key1& k1, DbTxn* txn)
- {
- return iterator(find_impl(&k1, txn->get_DB_TXN(), DB_SET|DB_MULTIPLE, BOOST_CURRENT_FUNCTION));
- }
- iterator find(const Key1& k1, const key2_t& k2, DB_TXN* txn = NULL)
- {
- return iterator(find_impl(&k1, &k2, txn, false, BOOST_CURRENT_FUNCTION));
- }
- iterator find(const Key1& k1, const key2_t& k2, DbTxn* txn)
- {
- return iterator(find_impl(&k1, &k2, txn->get_DB_TXN(), false, BOOST_CURRENT_FUNCTION));
- }
- iterator find_md(const Key1& k1, const key2_t& k2, DB_TXN* txn = NULL)
- {
- return iterator(find_impl(&k1, &k2, txn, true, BOOST_CURRENT_FUNCTION));
- }
- iterator find_md(const Key1& k1, const key2_t& k2, DbTxn* txn)
- {
- return iterator(find_impl(&k1, &k2, txn->get_DB_TXN(), true, BOOST_CURRENT_FUNCTION));
- }
- iterator lower_bound(const Key1& k1, DB_TXN* txn = NULL)
- {
- return iterator(find_impl(&k1, txn, DB_SET_RANGE|DB_MULTIPLE, BOOST_CURRENT_FUNCTION));
- }
- iterator lower_bound(const Key1& k1, DbTxn* txn)
- {
- return iterator(find_impl(&k1, txn->get_DB_TXN(), DB_SET_RANGE|DB_MULTIPLE, BOOST_CURRENT_FUNCTION));
- }
- iterator upper_bound(const Key1& k1, DB_TXN* txn = NULL)
- {
- return iterator(upper_bound_impl(&k1, txn, BOOST_CURRENT_FUNCTION));
- }
- bool insert(const Key1& k1, const Data& d, DB_TXN* txn = NULL)
- {
- return insert_impl(&k1, &d, txn, BOOST_CURRENT_FUNCTION);
- }
- bool insert(const Key1& k1, const Data& d, DbTxn* txn)
- {
- return insert_impl(&k1, &d, txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION);
- }
- bool replace(const Key1& k1, const Data& d, DB_TXN* txn = NULL)
- {
- return replace_impl(&k1, &d, txn, BOOST_CURRENT_FUNCTION);
- }
- bool replace(const Key1& k1, const Data& d, DbTxn* txn)
- {
- return replace_impl(&k1, &d, txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION);
- }
- bool remove(const Key1& k1, const key2_t& k2, DB_TXN* txn = NULL)
- {
- return remove_impl(&k1, &k2, txn, BOOST_CURRENT_FUNCTION);
- }
- bool remove(const Key1& k1, const key2_t& k2, DbTxn* txn)
- {
- return remove_impl(&k1, &k2, txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION);
- }
- bool remove(const Key1& k1, DB_TXN* txn = NULL)
- {
- return remove_impl(&k1, txn, BOOST_CURRENT_FUNCTION);
- }
- bool remove(const Key1& k1, DbTxn* txn)
- {
- return remove_impl(&k1, txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION);
- }
- bool erase(const iterator& iter)
- {
- return iter.remove();
- }
- void clear(DB_TXN* txn = NULL)
- {
- clear_impl(txn, BOOST_CURRENT_FUNCTION);
- }
- void clear(DbTxn* txn)
- {
- return clear_impl(txn->get_DB_TXN(), BOOST_CURRENT_FUNCTION);
- }
- void flush()
- {
- return flush_impl(BOOST_CURRENT_FUNCTION);
- }
- size_t count(const Key1& k1, DB_TXN* txn = NULL)
- {
- return count_impl(&k1, txn, BOOST_CURRENT_FUNCTION);
- }
- size_t count(const Key1& k1, DbTxn* txn)
- {
- return count_impl(&k1, txn ? txn->get_DB_TXN() : NULL, BOOST_CURRENT_FUNCTION);
- }
- DB* getDB() { return m_db; }
- const DB* getDB() const { return m_db; }
- };
- } // namespace febird
- #endif // __febird_bdb_kmapdset_h__
- /* vim: set tabstop=4 : */
- #include "kmapdset.h"
- //#include "../DataBuffer.h"
- #include <sstream>
- namespace febird {
- kmapdset_iterator_impl_base::kmapdset_iterator_impl_base(class kmapdset_base* owner)
- : m_owner(owner)
- , m_curp(0), m_ret(-1)
- {
- memset(&m_bulk, 0, sizeof(DBT));
- m_bulk.size = (owner->m_bulkSize);
- m_bulk.data = (::malloc(owner->m_bulkSize));
- m_bulk.flags = (DB_DBT_USERMEM);
- m_bulk.ulen = (owner->m_bulkSize);
- }
- void kmapdset_iterator_impl_base::init(DB* dbp, DB_TXN* txn, const char* func)
- {
- int ret = dbp->cursor(dbp, txn, &m_curp, 0);
- if (0 != ret)
- {
- delete this;
- std::ostringstream oss;
- oss << db_strerror(ret) << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- m_ret = 0;
- }
- kmapdset_iterator_impl_base::~kmapdset_iterator_impl_base()
- {
- if (m_bulk.data)
- ::free(m_bulk.data);
- if (m_curp)
- m_curp->close(m_curp);
- }
- bool kmapdset_iterator_impl_base::next_key(size_t* cnt, const char* func)
- {
- FEBIRD_RT_assert(0 == m_ret, std::logic_error);
- DBT tk1; memset(&tk1, 0, sizeof(DBT));
- m_ret = m_curp->get(m_curp, &tk1, &m_bulk, DB_NEXT_NODUP);
- if (0 == m_ret)
- {
- load_key1(tk1.data, tk1.size);
- db_recno_t cnt0 = 0;
- int ret = m_curp->count(m_curp, &cnt0, 0);
- if (0 != ret)
- {
- std::ostringstream oss;
- oss << db_strerror(ret) << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- *cnt = cnt0;
- return true;
- }
- else if (DB_NOTFOUND == m_ret)
- {
- return false;
- }
- else
- {
- std::ostringstream oss;
- oss << db_strerror(m_ret) << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- }
- void kmapdset_iterator_impl_base::bulk_load(DBT* tk1)
- {
- FEBIRD_RT_assert(0 == m_ret, std::logic_error);
- load_key1(tk1->data, tk1->size);
- clear_vec();
- int ret;
- do {
- void *bptr, *data;
- size_t size;
- DB_MULTIPLE_INIT(bptr, &m_bulk);
- assert(NULL != bptr);
- for (;;)
- {
- DB_MULTIPLE_NEXT(bptr, &m_bulk, data, size);
- if (bptr)
- this->push_back(data, size);
- else
- break;
- }
- ret = m_curp->get(m_curp, tk1, &m_bulk, DB_MULTIPLE|DB_NEXT_DUP);
- } while (0 == ret);
- }
- void kmapdset_iterator_impl_base::increment(const char* func)
- {
- FEBIRD_RT_assert(0 == m_ret, std::logic_error);
- DBT tk1; memset(&tk1, 0, sizeof(DBT));
- m_ret = m_curp->get(m_curp, &tk1, &m_bulk, DB_NEXT_NODUP|DB_MULTIPLE);
- if (0 == m_ret)
- {
- bulk_load(&tk1);
- }
- else if (DB_NOTFOUND != m_ret)
- {
- std::ostringstream oss;
- oss << db_strerror(m_ret) << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- }
- void kmapdset_iterator_impl_base::decrement(const char* func)
- {
- FEBIRD_RT_assert(0 == m_ret, std::logic_error);
- DBT tk1; memset(&tk1, 0, sizeof(DBT));
- m_ret = m_curp->get(m_curp, &tk1, &m_bulk, DB_PREV_NODUP);
- if (0 == m_ret)
- {
- m_ret = m_curp->get(m_curp, &tk1, &m_bulk, DB_CURRENT|DB_MULTIPLE);
- if (0 == m_ret)
- {
- bulk_load(&tk1);
- }
- else if (DB_KEYEMPTY == m_ret)
- {
- std::ostringstream oss;
- oss << db_strerror(m_ret)
- << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- }
- else if (DB_NOTFOUND != m_ret)
- {
- std::ostringstream oss;
- oss << db_strerror(m_ret) << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- }
- bool kmapdset_iterator_impl_base::find_pos(const void* k1, const void* k2, bool bulk, const char* func)
- {
- PortableDataOutput<AutoGrownMemIO> oKey1, oKey2;
- m_owner->save_key1(oKey1, k1);
- m_owner->save_key2(oKey2, k2);
- DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
- DBT tk2; memset(&tk2, 0, sizeof(DBT)); tk2.data = oKey2.begin(); tk2.size = oKey2.tell();
- m_ret = m_curp->get(m_curp, &tk1, &tk2, DB_GET_BOTH);
- if (0 == m_ret)
- {
- if (bulk) {
- m_ret = m_curp->get(m_curp, &tk1, &m_bulk, DB_CURRENT|DB_MULTIPLE);
- if (0 == m_ret) {
- bulk_load(&tk1);
- return true;
- }
- } else {
- clear_vec();
- load_key1(tk1.data, tk1.size);
- push_back(tk2.data, tk2.size);
- return true;
- }
- }
- else if (DB_NOTFOUND == m_ret)
- {
- return false;
- }
- std::ostringstream oss;
- oss << db_strerror(m_ret)
- << "... at: " << func
- << "\n"
- ;
- throw std::runtime_error(oss.str());
- }
- /**
- @brief
- @return true successful inserted
- false fail, (key1, d) existed, and not inserted
- @throw other errors
- */
- bool kmapdset_iterator_impl_base::insert(const void* d, const char* func)
- {
- FEBIRD_RT_assert(0 == m_ret || DB_NOTFOUND == m_ret || DB_KEYEXIST == m_ret, std::logic_error);
- PortableDataOutput<AutoGrownMemIO> oKey1, oData;
- this->save_key1(oKey1);
- m_owner->save_data(oData, d);
- DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
- DBT tdd; memset(&tdd, 0, sizeof(DBT)); tdd.data = oData.begin(); tdd.size = oData.tell();
- int ret = m_curp->put(m_curp, &tk1, &tdd, DB_NODUPDATA);
- if (DB_KEYEXIST == ret)
- return false;
- if (0 == ret)
- return true;
- std::ostringstream oss;
- oss << db_strerror(m_ret)
- << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- /**
- @brief
- @return true successful updated
- false (key1, d.key2) did not exist, not updated
- @throw other errors
- */
- bool kmapdset_iterator_impl_base::update(const void* d, const char* func)
- {
- FEBIRD_RT_assert(0 == m_ret, std::logic_error);
- PortableDataOutput<AutoGrownMemIO> oKey1, oData;
- this->save_key1(oKey1);
- m_owner->save_data(oData, d);
- DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
- DBT tdd; memset(&tdd, 0, sizeof(DBT)); tdd.data = oData.begin(); tdd.size = oData.tell();
- int ret = m_curp->get(m_curp, &tk1, &tdd, DB_GET_BOTH);
- if (0 == ret)
- {
- tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
- tdd.data = oData.begin(); tdd.size = oData.tell();
- ret = m_curp->put(m_curp, &tk1, &tdd, DB_CURRENT);
- if (0 == ret)
- return true;
- }
- else if (DB_NOTFOUND == ret)
- {
- return false;
- }
- std::ostringstream oss;
- oss << db_strerror(ret)
- << "... at: " << func;
- throw std::runtime_error(oss.str());
- }
- /**
- @brief
- @return true item was replaced by (key1,d)
- false item was inserted
- @throw other errors
- */
- bool kmapdset_iterator_impl_base::replace(const void* d, const char* func)
- {
- PortableDataOutput<AutoGrownMemIO> oKey1, oData;
- this->save_key1(oKey1);
- m_owner->save_data(oData, d);
- DBT tk1; memset(&tk1, 0, sizeof(DBT)); tk1.data = oKey1.begin(); tk1.size = oKey1.tell();
- DBT tdd; memset(&tdd, 0, sizeof(DBT)); tdd.data = oData.begin(); tdd.size = oData.tell();
- int ret = m_curp->get(m_curp, &tk1, &tdd, DB_GET_BOTH);
- if (0 == ret)
发表评论
-
检查序列化声明的顺序和成员定义的顺序
2009-04-11 16:12 1295项目地址:http://code.google.com/p/f ... -
febird.dataio 序列化宏
2009-04-08 11:23 1066序列化宏 DATA_IO_LOAD_SAVE( ... -
最便捷、最强大、速度最快的C++序列化框架
2008-11-07 18:08 2111最便捷、最强大、速度最快的C++序列化框架。 特别注意 ... -
持久化的 map ,使用 BerkeleyDB
2008-11-07 18:14 1116项目地址:http://code.google.com/p/f ... -
序列化如何简洁地支持XML
2009-01-02 14:24 991目前该框架(DataIO)仅支持二进制。想起序列化支持只需要一 ... -
febird.dataio 优化技术
2009-04-04 12:45 1332优化技术主要有以下几点: 1. 优化的inl ... -
febird.dataio和boost.serialization性能对比
2009-04-06 20:07 1598和boost.serialization性能对比 运行 ... -
febird.dataio vs boost.serialization 运行性能对比
2009-04-06 20:09 1075代码表示的是数据格式,DATA_IO_LOAD_SAVE 在 ...
相关推荐
4. **内存映射**:Berkeley DB支持将数据库文件映射到进程的内存空间,提高了数据访问速度,降低了I/O操作。 5. **跨平台兼容**:Berkeley DB可在多种操作系统上运行,包括Linux、Windows、Unix以及各种嵌入式系统...
LMDB(Lightning Memory-Mapped Database)是一种轻量级、高性能、嵌入式的键值对存储数据库,由Berkeley DB作者开发。它使用内存映射文件技术,将数据存储在磁盘上,但通过内存映射使得访问速度接近于内存。这种...
Oracle中的BDB(Berkeley DB)数据库是一种轻量级、高性能的数据存储解决方案,尤其适合用于对数据快速存取和小型项目的需求。BDB是Oracle公司收购Sleepycat Software后得到的一种开源、嵌入式数据库系统,它以键/值...
Java中的磁盘KV存储是指将键值对(Key-Value pairs)的数据结构持久化到硬盘上,以便在程序运行期间可以高效地进行读写操作。JDBM2是一个开源的、基于Java实现的磁盘KV存储系统,它提供了一种在Java应用程序中实现...
BoltDB 是一款轻量级、嵌入式的键值对数据库,主要应用于Go语言环境。它的设计灵感来自于 Berkeley DB,但简化...在实际开发中,BoltDB因其简洁和高效,常被用于需要本地持久化存储的场景,例如配置管理、缓存服务等。
`lmdb`在Python中的应用主要涉及到数据持久化、高速查找和低延迟的数据访问场景。 **1. LMDB的特点** - **内存映射**:LMDB使用内存映射文件技术,将数据库存储直接映射到进程地址空间,极大地提高了读取速度。 - ...
LMDB(Lightning Memory-Mapped Database)是一种高效、小巧、基于内存映射的键值存储系统,由Berkeley DB的作者之一Jeffrey Stedfast开发。这个“lmdb-mdb.master.rar”压缩包包含了LMDB数据库在Windows平台上的...
- **数据持久化**:即使在程序崩溃或系统断电后,也能确保数据不丢失,因为所有更改都会被立即持久化到磁盘上。 - **空间效率**:自动进行数据压缩,有效节省存储空间。 2. **lmdb的使用** - **安装**:在Python...
例如,BerkeleyDB、Tokyo Cabinet 和 Innostore 等系统在某些方面表现良好,但在其他方面则不尽如人意。这些系统的局限性激发了Riak团队寻找更好的解决方案。 #### 关键洞见 在讨论这个问题时,Eric Brewer 提出了...
第7章 持久化和数据库 273 引言 273 7.1 使用marshal模块序列化数据 275 7.2 使用pickle和cPickle模块序列化数据 277 7.3 在Pickling的时候压缩 280 7.4 对类和实例使用cPickle模块 281 7.5 Pickling被绑定...