diff --git a/src/os/memstore/MemStore.cc b/src/os/memstore/MemStore.cc index 908da42f0c342..c837c577afa66 100644 --- a/src/os/memstore/MemStore.cc +++ b/src/os/memstore/MemStore.cc @@ -597,6 +597,51 @@ int MemStore::omap_check_keys( return 0; } +class MemStore::OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl { + CollectionRef c; + ObjectRef o; + map::iterator it; +public: + OmapIteratorImpl(CollectionRef c, ObjectRef o) + : c(c), o(o), it(o->omap.begin()) {} + + int seek_to_first() { + std::lock_guard(o->omap_mutex); + it = o->omap.begin(); + return 0; + } + int upper_bound(const string &after) { + std::lock_guard(o->omap_mutex); + it = o->omap.upper_bound(after); + return 0; + } + int lower_bound(const string &to) { + std::lock_guard(o->omap_mutex); + it = o->omap.lower_bound(to); + return 0; + } + bool valid() { + std::lock_guard(o->omap_mutex); + return it != o->omap.end(); + } + int next(bool validate=true) { + std::lock_guard(o->omap_mutex); + ++it; + return 0; + } + string key() { + std::lock_guard(o->omap_mutex); + return it->first; + } + bufferlist value() { + std::lock_guard(o->omap_mutex); + return it->second; + } + int status() { + return 0; + } +}; + ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(const coll_t& cid, const ghobject_t& oid) { diff --git a/src/os/memstore/MemStore.h b/src/os/memstore/MemStore.h index abd6f87070c88..35a59d71fb3e4 100644 --- a/src/os/memstore/MemStore.h +++ b/src/os/memstore/MemStore.h @@ -253,50 +253,7 @@ class MemStore : public ObjectStore { typedef Collection::Ref CollectionRef; private: - class OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl { - CollectionRef c; - ObjectRef o; - map::iterator it; - public: - OmapIteratorImpl(CollectionRef c, ObjectRef o) - : c(c), o(o), it(o->omap.begin()) {} - - int seek_to_first() { - std::lock_guard(o->omap_mutex); - it = o->omap.begin(); - return 0; - } - int upper_bound(const string &after) { - std::lock_guard(o->omap_mutex); - it = o->omap.upper_bound(after); - return 0; - } - int lower_bound(const string &to) { - std::lock_guard(o->omap_mutex); - it = o->omap.lower_bound(to); - return 0; - } - bool valid() { - std::lock_guard(o->omap_mutex); - return it != o->omap.end(); - } - int next(bool validate=true) { - std::lock_guard(o->omap_mutex); - ++it; - return 0; - } - string key() { - std::lock_guard(o->omap_mutex); - return it->first; - } - bufferlist value() { - std::lock_guard(o->omap_mutex); - return it->second; - } - int status() { - return 0; - } - }; + class OmapIteratorImpl; ceph::unordered_map coll_map;