Skip to content

Commit

Permalink
Merge pull request #10803 from stiopaa1/os_memstore_moveOmapIteratorI…
Browse files Browse the repository at this point in the history
…mplClassToCC

os/MemStore: move OmapIteratorImpl to cc file

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Aug 23, 2016
2 parents b7c7941 + dfcccf6 commit ddb8125
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
45 changes: 45 additions & 0 deletions src/os/memstore/MemStore.cc
Expand Up @@ -597,6 +597,51 @@ int MemStore::omap_check_keys(
return 0;
}

class MemStore::OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl {
CollectionRef c;
ObjectRef o;
map<string,bufferlist>::iterator it;
public:
OmapIteratorImpl(CollectionRef c, ObjectRef o)
: c(c), o(o), it(o->omap.begin()) {}

int seek_to_first() {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.begin();
return 0;
}
int upper_bound(const string &after) {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.upper_bound(after);
return 0;
}
int lower_bound(const string &to) {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.lower_bound(to);
return 0;
}
bool valid() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it != o->omap.end();
}
int next(bool validate=true) {
std::lock_guard<std::mutex>(o->omap_mutex);
++it;
return 0;
}
string key() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it->first;
}
bufferlist value() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it->second;
}
int status() {
return 0;
}
};

ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(const coll_t& cid,
const ghobject_t& oid)
{
Expand Down
45 changes: 1 addition & 44 deletions src/os/memstore/MemStore.h
Expand Up @@ -253,50 +253,7 @@ class MemStore : public ObjectStore {
typedef Collection::Ref CollectionRef;

private:
class OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl {
CollectionRef c;
ObjectRef o;
map<string,bufferlist>::iterator it;
public:
OmapIteratorImpl(CollectionRef c, ObjectRef o)
: c(c), o(o), it(o->omap.begin()) {}

int seek_to_first() {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.begin();
return 0;
}
int upper_bound(const string &after) {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.upper_bound(after);
return 0;
}
int lower_bound(const string &to) {
std::lock_guard<std::mutex>(o->omap_mutex);
it = o->omap.lower_bound(to);
return 0;
}
bool valid() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it != o->omap.end();
}
int next(bool validate=true) {
std::lock_guard<std::mutex>(o->omap_mutex);
++it;
return 0;
}
string key() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it->first;
}
bufferlist value() {
std::lock_guard<std::mutex>(o->omap_mutex);
return it->second;
}
int status() {
return 0;
}
};
class OmapIteratorImpl;


ceph::unordered_map<coll_t, CollectionRef> coll_map;
Expand Down

0 comments on commit ddb8125

Please sign in to comment.