summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/os/CollectionIndex.h5
-rw-r--r--src/os/DBObjectMap.cc90
-rw-r--r--src/os/DBObjectMap.h38
-rw-r--r--src/os/FileStore.cc27
-rw-r--r--src/os/HashIndex.cc1
-rw-r--r--src/os/IndexManager.cc2
-rw-r--r--src/os/LFNIndex.h1
-rw-r--r--src/os/ObjectMap.h38
-rw-r--r--src/test/ObjectMap/test_object_map.cc58
9 files changed, 140 insertions, 120 deletions
diff --git a/src/os/CollectionIndex.h b/src/os/CollectionIndex.h
index 0efa6459ec8..30e877c4923 100644
--- a/src/os/CollectionIndex.h
+++ b/src/os/CollectionIndex.h
@@ -64,6 +64,11 @@ protected:
/// Getter for collection
coll_t coll() const { return parent_coll; }
+
+ /// Getter for parent
+ std::tr1::shared_ptr<CollectionIndex> get_index() const {
+ return parent_ref;
+ }
};
public:
/// Type of returned paths
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index 0586cd719e8..f425d88223c 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/DBObjectMap.cc
@@ -12,7 +12,7 @@
#include <vector>
#include <tr1/memory>
-#include "CollectionIndex.h"
+#include "IndexManager.h"
#include "ObjectMap.h"
#include "KeyValueDB.h"
#include "DBObjectMap.h"
@@ -193,9 +193,9 @@ int DBObjectMap::DBObjectMapIteratorImpl::init()
ObjectMap::ObjectMapIterator DBObjectMap::get_iterator(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path)
+ Index index)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return ObjectMapIterator(new EmptyIteratorImpl());
return _get_iterator(header);
@@ -379,11 +379,11 @@ int DBObjectMap::DBObjectMapIteratorImpl::status()
}
int DBObjectMap::set_keys(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const map<string, bufferlist> &set)
{
KeyValueDB::Transaction t = db->get_transaction();
- Header header = lookup_create_map_header(path->coll(), hoid, t);
+ Header header = lookup_create_map_header(index->coll(), hoid, t);
if (!header)
return -EINVAL;
@@ -393,11 +393,11 @@ int DBObjectMap::set_keys(const hobject_t &hoid,
}
int DBObjectMap::set_header(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const bufferlist &bl)
{
KeyValueDB::Transaction t = db->get_transaction();
- Header header = lookup_create_map_header(path->coll(), hoid, t);
+ Header header = lookup_create_map_header(index->coll(), hoid, t);
if (!header)
return -EINVAL;
_set_header(header, bl, t);
@@ -413,10 +413,10 @@ void DBObjectMap::_set_header(Header header, const bufferlist &bl,
}
int DBObjectMap::get_header(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
bufferlist *bl)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header) {
return 0;
}
@@ -449,13 +449,13 @@ int DBObjectMap::_get_header(Header header,
}
int DBObjectMap::clear(const hobject_t &hoid,
- CollectionIndex::IndexedPath path)
+ Index index)
{
KeyValueDB::Transaction t = db->get_transaction();
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
- remove_map_header(path->coll(), hoid, header, t);
+ remove_map_header(index->coll(), hoid, header, t);
assert(header->num_children > 0);
header->num_children--;
int r = _clear(header, t);
@@ -568,10 +568,10 @@ int DBObjectMap::need_parent(DBObjectMapIterator iter)
}
int DBObjectMap::rm_keys(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_clear)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
KeyValueDB::Transaction t = db->get_transaction();
@@ -641,11 +641,11 @@ int DBObjectMap::rm_keys(const hobject_t &hoid,
}
int DBObjectMap::get(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
bufferlist *_header,
map<string, bufferlist> *out)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
_get_header(header, _header);
@@ -659,13 +659,13 @@ int DBObjectMap::get(const hobject_t &hoid,
}
int DBObjectMap::get_keys(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
set<string> *keys)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
- ObjectMapIterator iter = get_iterator(hoid, path);
+ ObjectMapIterator iter = get_iterator(hoid, index);
for (; iter->valid(); iter->next()) {
if (iter->status())
return iter->status();
@@ -697,43 +697,43 @@ int DBObjectMap::scan(Header header,
}
int DBObjectMap::get_values(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &keys,
map<string, bufferlist> *out)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
return scan(header, keys, 0, out);;
}
int DBObjectMap::check_keys(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &keys,
set<string> *out)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
return scan(header, keys, out, 0);
}
int DBObjectMap::get_xattrs(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_get,
map<string, bufferlist> *out)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
return db->get(xattr_prefix(header), to_get, out);
}
int DBObjectMap::get_all_xattrs(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
set<string> *out)
{
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
KeyValueDB::Iterator iter = db->get_iterator(xattr_prefix(header));
@@ -745,11 +745,11 @@ int DBObjectMap::get_all_xattrs(const hobject_t &hoid,
}
int DBObjectMap::set_xattrs(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const map<string, bufferlist> &to_set)
{
KeyValueDB::Transaction t = db->get_transaction();
- Header header = lookup_create_map_header(path->coll(), hoid, t);
+ Header header = lookup_create_map_header(index->coll(), hoid, t);
if (!header)
return -EINVAL;
t->set(xattr_prefix(header), to_set);
@@ -757,11 +757,11 @@ int DBObjectMap::set_xattrs(const hobject_t &hoid,
}
int DBObjectMap::remove_xattrs(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_remove)
{
KeyValueDB::Transaction t = db->get_transaction();
- Header header = lookup_map_header(path->coll(), hoid);
+ Header header = lookup_map_header(index->coll(), hoid);
if (!header)
return -ENOENT;
t->rmkeys(xattr_prefix(header), to_remove);
@@ -769,26 +769,26 @@ int DBObjectMap::remove_xattrs(const hobject_t &hoid,
}
int DBObjectMap::clone(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const hobject_t &target,
- CollectionIndex::IndexedPath target_path)
+ Index target_index)
{
KeyValueDB::Transaction t = db->get_transaction();
{
- Header destination = lookup_map_header(target_path->coll(), target);
+ Header destination = lookup_map_header(target_index->coll(), target);
if (destination) {
- remove_map_header(target_path->coll(), target, destination, t);
+ remove_map_header(target_index->coll(), target, destination, t);
destination->num_children--;
_clear(destination, t);
}
}
- Header parent = lookup_map_header(path->coll(), hoid);
+ Header parent = lookup_map_header(index->coll(), hoid);
if (!parent)
return db->submit_transaction(t);
- Header source = generate_new_header(path->coll(), hoid, parent);
- Header destination = generate_new_header(target_path->coll(), target, parent);
+ Header source = generate_new_header(index->coll(), hoid, parent);
+ Header destination = generate_new_header(target_index->coll(), target, parent);
_Header lsource, ldestination;
source->num_children = parent->num_children;
lsource.parent = source->seq;
@@ -797,7 +797,7 @@ int DBObjectMap::clone(const hobject_t &hoid,
set_header(parent, t);
set_header(source, t);
set_header(destination, t);
- set_map_header(target_path->coll(), target, ldestination, t);
+ set_map_header(target_index->coll(), target, ldestination, t);
map<string, bufferlist> to_set;
KeyValueDB::Iterator xattr_iter = db->get_iterator(xattr_prefix(parent));
@@ -827,27 +827,27 @@ int DBObjectMap::clone(const hobject_t &hoid,
}
int DBObjectMap::link(const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const hobject_t &target,
- CollectionIndex::IndexedPath target_path)
+ Index target_index)
{
KeyValueDB::Transaction t = db->get_transaction();
{
- Header destination = lookup_map_header(target_path->coll(), target);
+ Header destination = lookup_map_header(target_index->coll(), target);
if (destination) {
- remove_map_header(target_path->coll(), target, destination, t);
+ remove_map_header(target_index->coll(), target, destination, t);
destination->num_children--;
_clear(destination, t);
}
}
- Header header = lookup_create_map_header(path->coll(), hoid, t);
+ Header header = lookup_create_map_header(index->coll(), hoid, t);
assert(header->num_children > 0);
header->num_children++;
set_header(header, t);
_Header ldestination;
ldestination.parent = header->seq;
- set_map_header(target_path->coll(), target, ldestination, t);
+ set_map_header(target_index->coll(), target, ldestination, t);
return db->submit_transaction(t);
}
diff --git a/src/os/DBObjectMap.h b/src/os/DBObjectMap.h
index e26d7351fb6..2c3e66d1c51 100644
--- a/src/os/DBObjectMap.h
+++ b/src/os/DBObjectMap.h
@@ -12,7 +12,7 @@
#include <tr1/memory>
#include <boost/scoped_ptr.hpp>
-#include "CollectionIndex.h"
+#include "IndexManager.h"
#include "ObjectMap.h"
#include "KeyValueDB.h"
#include "osd/osd_types.h"
@@ -82,97 +82,97 @@ public:
int set_keys(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const map<string, bufferlist> &set
);
int set_header(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const bufferlist &bl
);
int get_header(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
bufferlist *bl
);
int clear(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path
+ Index index
);
int rm_keys(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_clear
);
int get(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
bufferlist *header,
map<string, bufferlist> *out
);
int get_keys(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
set<string> *keys
);
int get_values(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &keys,
map<string, bufferlist> *out
);
int check_keys(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &keys,
set<string> *out
);
int get_xattrs(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_get,
map<string, bufferlist> *out
);
int get_all_xattrs(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
set<string> *out
);
int set_xattrs(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const map<string, bufferlist> &to_set
);
int remove_xattrs(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const set<string> &to_remove
);
int clone(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const hobject_t &target,
- CollectionIndex::IndexedPath target_path
+ Index target_index
);
int link(
const hobject_t &hoid,
- CollectionIndex::IndexedPath path,
+ Index index,
const hobject_t &target,
- CollectionIndex::IndexedPath target_path
+ Index target_index
);
/// Read initial state from backing store
@@ -185,7 +185,7 @@ public:
int sync();
ObjectMapIterator get_iterator(const hobject_t &hoid,
- CollectionIndex::IndexedPath path);
+ Index index);
static const string USER_PREFIX;
static const string XATTR_PREFIX;
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index f0833631f2c..5b5f72d8b67 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -345,7 +345,8 @@ int FileStore::lfn_link(coll_t c, coll_t cid, const hobject_t& o)
if (r < 0)
return -errno;
- r = object_map->link(o, path_old, o, path_new);
+ r = object_map->link(o, path_old->get_index(),
+ o, path_new->get_index());
if (r < 0)
return r;
@@ -367,7 +368,7 @@ int FileStore::lfn_unlink(coll_t cid, const hobject_t& o)
r = index->lookup(o, &path, &exist);
if (r < 0)
return r;
- object_map->clear(o, path);
+ object_map->clear(o, path->get_index());
if (r < 0 && r != -ENOENT)
return r;
}
@@ -3061,7 +3062,7 @@ int FileStore::_clone(coll_t cid, const hobject_t& oldoid, const hobject_t& newo
if (r < 0)
r = -errno;
dout(20) << "objectmap clone" << dendl;
- r = object_map->clone(oldoid, from, newoid, to);
+ r = object_map->clone(oldoid, from->get_index(), newoid, to->get_index());
// clone is non-idempotent; record our work.
_set_replay_guard(n, spos);
@@ -4153,7 +4154,7 @@ int FileStore::omap_get(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- return object_map->get(hoid, path, header, out);
+ return object_map->get(hoid, path->get_index(), header, out);
}
int FileStore::omap_get_header(coll_t c, const hobject_t &hoid,
@@ -4164,7 +4165,7 @@ int FileStore::omap_get_header(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- return object_map->get_header(hoid, path, bl);
+ return object_map->get_header(hoid, path->get_index(), bl);
}
int FileStore::omap_get_keys(coll_t c, const hobject_t &hoid, set<string> *keys)
@@ -4174,7 +4175,7 @@ int FileStore::omap_get_keys(coll_t c, const hobject_t &hoid, set<string> *keys)
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- return object_map->get_keys(hoid, path, keys);
+ return object_map->get_keys(hoid, path->get_index(), keys);
}
int FileStore::omap_get_values(coll_t c, const hobject_t &hoid,
@@ -4186,7 +4187,7 @@ int FileStore::omap_get_values(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- return object_map->get_values(hoid, path, keys, out);
+ return object_map->get_values(hoid, path->get_index(), keys, out);
}
int FileStore::omap_check_keys(coll_t c, const hobject_t &hoid,
@@ -4198,7 +4199,7 @@ int FileStore::omap_check_keys(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- return object_map->check_keys(hoid, path, keys, out);
+ return object_map->check_keys(hoid, path->get_index(), keys, out);
}
ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c,
@@ -4209,7 +4210,7 @@ ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return ObjectMap::ObjectMapIterator();
- return object_map->get_iterator(hoid, path);
+ return object_map->get_iterator(hoid, path->get_index());
}
int FileStore::_create_collection(coll_t c)
@@ -4283,7 +4284,7 @@ int FileStore::_omap_clear(coll_t cid, const hobject_t &hoid) {
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->clear(hoid, path);
+ return object_map->clear(hoid, path->get_index());
}
int FileStore::_omap_setkeys(coll_t cid, const hobject_t &hoid,
const map<string, bufferlist> &aset) {
@@ -4292,7 +4293,7 @@ int FileStore::_omap_setkeys(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->set_keys(hoid, path, aset);
+ return object_map->set_keys(hoid, path->get_index(), aset);
}
int FileStore::_omap_rmkeys(coll_t cid, const hobject_t &hoid,
const set<string> &keys) {
@@ -4301,7 +4302,7 @@ int FileStore::_omap_rmkeys(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->rm_keys(hoid, path, keys);
+ return object_map->rm_keys(hoid, path->get_index(), keys);
}
int FileStore::_omap_setheader(coll_t cid, const hobject_t &hoid,
const bufferlist &bl)
@@ -4311,7 +4312,7 @@ int FileStore::_omap_setheader(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->set_header(hoid, path, bl);
+ return object_map->set_header(hoid, path->get_index(), bl);
}
diff --git a/src/os/HashIndex.cc b/src/os/HashIndex.cc
index c51f9d65927..a47f457e83b 100644
--- a/src/os/HashIndex.cc
+++ b/src/os/HashIndex.cc
@@ -15,6 +15,7 @@
#include "include/types.h"
#include "include/buffer.h"
#include "osd/osd_types.h"
+#include <errno.h>
#include "HashIndex.h"
diff --git a/src/os/IndexManager.cc b/src/os/IndexManager.cc
index 808525edcc7..e1e226397b7 100644
--- a/src/os/IndexManager.cc
+++ b/src/os/IndexManager.cc
@@ -19,6 +19,8 @@
#include <sys/param.h>
#endif
+#include <errno.h>
+
#include "common/Mutex.h"
#include "common/Cond.h"
#include "common/config.h"
diff --git a/src/os/LFNIndex.h b/src/os/LFNIndex.h
index 54578a68dcf..542da55c3c1 100644
--- a/src/os/LFNIndex.h
+++ b/src/os/LFNIndex.h
@@ -25,7 +25,6 @@
#include "osd/osd_types.h"
#include "include/object.h"
#include "common/ceph_crypto.h"
-#include "ObjectStore.h"
#include "CollectionIndex.h"
diff --git a/src/os/ObjectMap.h b/src/os/ObjectMap.h
index d274fdbabc1..0f3088e641e 100644
--- a/src/os/ObjectMap.h
+++ b/src/os/ObjectMap.h
@@ -19,7 +19,7 @@
#include <vector>
#include <tr1/memory>
-#include "CollectionIndex.h"
+#include "IndexManager.h"
/**
* Encapsulates the FileStore key value store
@@ -31,41 +31,41 @@ public:
/// Set keys and values from specified map
virtual int set_keys(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const map<string, bufferlist> &set ///< [in] key to value map to set
) = 0;
/// Set header
virtual int set_header(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const bufferlist &bl ///< [in] header to set
) = 0;
/// Retrieve header
virtual int get_header(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
bufferlist *bl ///< [out] header to set
) = 0;
/// Clear all map keys and values from hoid
virtual int clear(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path ///< [in] Path to hoid
+ Index index ///< [in] Path to hoid
) = 0;
/// Clear all map keys and values from hoid
virtual int rm_keys(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const set<string> &to_clear ///< [in] Keys to clear
) = 0;
/// Get all keys and values
virtual int get(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
bufferlist *header, ///< [out] Returned Header
map<string, bufferlist> *out ///< [out] Returned keys and values
) = 0;
@@ -73,14 +73,14 @@ public:
/// Get values for supplied keys
virtual int get_keys(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
set<string> *keys ///< [out] Keys defined on hoid
) = 0;
/// Get values for supplied keys
virtual int get_values(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const set<string> &keys, ///< [in] Keys to get
map<string, bufferlist> *out ///< [out] Returned keys and values
) = 0;
@@ -88,7 +88,7 @@ public:
/// Check key existence
virtual int check_keys(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const set<string> &keys, ///< [in] Keys to check
set<string> *out ///< [out] Subset of keys defined on hoid
) = 0;
@@ -96,7 +96,7 @@ public:
/// Get xattrs
virtual int get_xattrs(
const hobject_t &hoid, ///< [in] object
- CollectionIndex::IndexedPath path, ///< [in] path to hoid
+ Index index, ///< [in] path to hoid
const set<string> &to_get, ///< [in] keys to get
map<string, bufferlist> *out ///< [out] subset of attrs/vals defined
) = 0;
@@ -104,21 +104,21 @@ public:
/// Get all xattrs
virtual int get_all_xattrs(
const hobject_t &hoid, ///< [in] object
- CollectionIndex::IndexedPath path, ///< [in] path to hoid
+ Index index, ///< [in] path to hoid
set<string> *out ///< [out] attrs and values
) = 0;
/// set xattrs in to_set
virtual int set_xattrs(
const hobject_t &hoid, ///< [in] object
- CollectionIndex::IndexedPath path, ///< [in] path to object
+ Index index, ///< [in] path to object
const map<string, bufferlist> &to_set ///< [in] attrs/values to set
) = 0;
/// remove xattrs in to_remove
virtual int remove_xattrs(
const hobject_t &hoid, ///< [in] object
- CollectionIndex::IndexedPath path, ///< [in] path to hoid
+ Index index, ///< [in] path to hoid
const set<string> &to_remove ///< [in] attrs to remove
) = 0;
@@ -126,17 +126,17 @@ public:
/// Clone keys efficiently from hoid map to target map
virtual int clone(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const hobject_t &target, ///< [in] target of clone
- CollectionIndex::IndexedPath target_path ///< [in] path to target
+ Index target_index ///< [in] path to target
) { return 0; }
/// Efficiently tie <target, target_path> to same key space as <hoid, path>
virtual int link(
const hobject_t &hoid, ///< [in] object containing map
- CollectionIndex::IndexedPath path, ///< [in] Path to hoid
+ Index index, ///< [in] Path to hoid
const hobject_t &target, ///< [in] target of link
- CollectionIndex::IndexedPath target_path ///< [in] path to target
+ Index target_index ///< [in] path to target
) { return 0; }
/// Ensure all previous writes are durable
@@ -158,7 +158,7 @@ public:
};
typedef std::tr1::shared_ptr<ObjectMapIteratorImpl> ObjectMapIterator;
virtual ObjectMapIterator get_iterator(const hobject_t &hoid,
- CollectionIndex::IndexedPath path) {
+ Index index) {
return ObjectMapIterator();
}
diff --git a/src/test/ObjectMap/test_object_map.cc b/src/test/ObjectMap/test_object_map.cc
index ef91f1606d7..ac551f5dd1b 100644
--- a/src/test/ObjectMap/test_object_map.cc
+++ b/src/test/ObjectMap/test_object_map.cc
@@ -1,13 +1,15 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
#include <tr1/memory>
#include <map>
#include <set>
#include <boost/scoped_ptr.hpp>
-#include "os/CollectionIndex.h"
+#include "os/IndexManager.h"
#include "include/buffer.h"
#include "test/ObjectMap/KeyValueDBMemory.h"
#include "os/KeyValueDB.h"
#include "os/DBObjectMap.h"
+#include "os/HashIndex.h"
#include "os/LevelDBStore.h"
#include <sys/types.h>
#include "global/global_init.h"
@@ -45,7 +47,7 @@ public:
map<string, map<string, string> > omap;
map<string, string > hmap;
map<string, map<string, string> > xattrs;
- CollectionIndex::IndexedPath def_collection;
+ Index def_collection;
unsigned seq;
ObjectMapTest() : db(), seq(0) {}
@@ -85,7 +87,7 @@ public:
key, value);
}
- void set_key(hobject_t hoid, CollectionIndex::IndexedPath path,
+ void set_key(hobject_t hoid, Index path,
string key, string value) {
map<string, bufferlist> to_write;
bufferptr bp(value.c_str(), value.size());
@@ -95,7 +97,7 @@ public:
db->set_keys(hoid, path, to_write);
}
- void set_xattr(hobject_t hoid, CollectionIndex::IndexedPath path,
+ void set_xattr(hobject_t hoid, Index path,
string key, string value) {
map<string, bufferlist> to_write;
bufferptr bp(value.c_str(), value.size());
@@ -110,7 +112,7 @@ public:
value);
}
- void set_header(hobject_t hoid, CollectionIndex::IndexedPath path,
+ void set_header(hobject_t hoid, Index path,
const string &value) {
bufferlist header;
header.append(bufferptr(value.c_str(), value.size() + 1));
@@ -122,7 +124,7 @@ public:
value);
}
- int get_header(hobject_t hoid, CollectionIndex::IndexedPath path,
+ int get_header(hobject_t hoid, Index path,
string *value) {
bufferlist header;
int r = db->get_header(hoid, path, &header);
@@ -140,7 +142,7 @@ public:
key, value);
}
- int get_xattr(hobject_t hoid, CollectionIndex::IndexedPath path,
+ int get_xattr(hobject_t hoid, Index path,
string key, string *value) {
set<string> to_get;
to_get.insert(key);
@@ -160,7 +162,7 @@ public:
key, value);
}
- int get_key(hobject_t hoid, CollectionIndex::IndexedPath path,
+ int get_key(hobject_t hoid, Index path,
string key, string *value) {
set<string> to_get;
to_get.insert(key);
@@ -180,7 +182,7 @@ public:
key);
}
- void remove_key(hobject_t hoid, CollectionIndex::IndexedPath path,
+ void remove_key(hobject_t hoid, Index path,
string key) {
set<string> to_remove;
to_remove.insert(key);
@@ -192,7 +194,7 @@ public:
key);
}
- void remove_xattr(hobject_t hoid, CollectionIndex::IndexedPath path,
+ void remove_xattr(hobject_t hoid, Index path,
string key) {
set<string> to_remove;
to_remove.insert(key);
@@ -204,8 +206,8 @@ public:
hobject_t(sobject_t(target, CEPH_NOSNAP)), def_collection);
}
- void clone(hobject_t hoid, CollectionIndex::IndexedPath path,
- hobject_t hoid2, CollectionIndex::IndexedPath path2) {
+ void clone(hobject_t hoid, Index path,
+ hobject_t hoid2, Index path2) {
db->clone(hoid, path, hoid2, path2);
}
@@ -213,7 +215,7 @@ public:
clear(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection);
}
- void clear(hobject_t hoid, CollectionIndex::IndexedPath path) {
+ void clear(hobject_t hoid, Index path) {
db->clear(hoid, path);
}
@@ -236,8 +238,11 @@ public:
}
void init_default_collection(const string &coll_name) {
- def_collection = CollectionIndex::get_testing_path(
- "/" + coll_name, coll_t(coll_name));
+ def_collection = Index(new HashIndex(coll_t(coll_name),
+ ("/" + coll_name).c_str(),
+ 2,
+ 2,
+ CollectionIndex::HASH_INDEX_TAG_2));
}
void auto_set_xattr(ostream &out) {
@@ -542,9 +547,11 @@ int main(int argc, char **argv) {
TEST_F(ObjectMapTest, CreateOneObject) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
- CollectionIndex::IndexedPath path = CollectionIndex::get_testing_path(
- "/bar", coll_t("foo_coll"));
-
+ Index path = Index(new HashIndex(coll_t("foo_coll"),
+ string("/bar").c_str(),
+ 2,
+ 2,
+ CollectionIndex::HASH_INDEX_TAG_2));
map<string, bufferlist> to_set;
string key("test");
string val("test_val");
@@ -582,8 +589,11 @@ TEST_F(ObjectMapTest, CreateOneObject) {
TEST_F(ObjectMapTest, CloneOneObject) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
hobject_t hoid2(sobject_t("foo2", CEPH_NOSNAP));
- CollectionIndex::IndexedPath path = CollectionIndex::get_testing_path(
- "/bar", coll_t("foo_coll"));
+ Index path = Index(new HashIndex(coll_t("foo_coll"),
+ string("/bar").c_str(),
+ 2,
+ 2,
+ CollectionIndex::HASH_INDEX_TAG_2));
set_key(hoid, path, "foo", "bar");
set_key(hoid, path, "foo2", "bar2");
@@ -646,9 +656,11 @@ TEST_F(ObjectMapTest, OddEvenClone) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
hobject_t hoid2(sobject_t("foo2", CEPH_NOSNAP));
hobject_t hoid_link(sobject_t("foo_link", CEPH_NOSNAP));
- CollectionIndex::IndexedPath path = CollectionIndex::get_testing_path(
- "/bar", coll_t("foo_coll"));
-
+ Index path = Index(new HashIndex(coll_t("foo_coll"),
+ string("/bar").c_str(),
+ 2,
+ 2,
+ CollectionIndex::HASH_INDEX_TAG_2));
for (unsigned i = 0; i < 1000; ++i) {
set_key(hoid, path, "foo" + num_str(i), "bar" + num_str(i));