#include "osd/osd_types.h"
#include "include/object.h"
-#include "ObjectStore.h"
/**
* CollectionIndex provides an interface for manipulating indexed colelctions
string full_path;
/// Ref to parent Index
std::tr1::shared_ptr<CollectionIndex> parent_ref;
- /// Constructor
+ /// coll_t for parent Index
+ coll_t parent_coll;
+
+ /// Normal Constructor
Path(
string path, ///< [in] Path to return.
std::tr1::weak_ptr<CollectionIndex> ref) ///< [in] weak_ptr to parent.
- : full_path(path), parent_ref(ref) {}
+ : full_path(path), parent_ref(ref), parent_coll(parent_ref->coll()) {}
+
+ /// Debugging Constructor
+ Path(
+ string path, ///< [in] Path to return.
+ coll_t coll) ///< [in] collection
+ : full_path(path), parent_coll(coll) {}
/// Getter for the stored path.
const char *path() const { return full_path.c_str(); }
+
+ /// Getter for collection
+ coll_t coll() const { return parent_coll; }
};
public:
/// Type of returned paths
typedef std::tr1::shared_ptr<Path> IndexedPath;
+ static IndexedPath get_testing_path(string path, coll_t collection) {
+ return IndexedPath(new Path(path, collection));
+ }
+
static const uint32_t FLAT_INDEX_TAG = 0;
static const uint32_t HASH_INDEX_TAG = 1;
static const uint32_t HASH_INDEX_TAG_2 = 2;
*/
virtual uint32_t collection_version() = 0;
+ /**
+ * Returns the collection managed by this CollectionIndex
+ */
+ virtual coll_t coll() const = 0;
+
/**
* For setting the internal weak_ptr to a shared_ptr to this.
*
#include "CollectionIndex.h"
#include "common/ceph_crypto.h"
#include "osd/osd_types.h"
+#include <errno.h>
using ceph::crypto::SHA1;
class FlatIndex : public CollectionIndex {
std::tr1::weak_ptr<CollectionIndex> self_ref;
string base_path;
+ coll_t collection;
public:
- FlatIndex(string base_path) : base_path(base_path) {}
+ FlatIndex(coll_t collection, string base_path) : base_path(base_path),
+ collection(collection) {}
/// @see CollectionIndex
uint32_t collection_version() { return FLAT_INDEX_TAG; }
+ coll_t coll() const { return collection; }
+
/// @see CollectionIndex
void set_ref(std::tr1::shared_ptr<CollectionIndex> ref);
public:
/// Constructor.
HashIndex(
+ coll_t collection, ///< [in] Collection
const char *base_path, ///< [in] Path to the index root.
int merge_at, ///< [in] Merge threshhold.
int split_multiple, ///< [in] Split threshhold.
uint32_t index_version)///< [in] Index version
- : LFNIndex(base_path, index_version), merge_threshold(merge_at),
+ : LFNIndex(collection, base_path, index_version), merge_threshold(merge_at),
split_multiplier(split_multiple) {}
/// @see CollectionIndex
int r = set_version(path, version);
if (r < 0)
return r;
- HashIndex index(path, g_conf->filestore_merge_threshold,
+ HashIndex index(c, path, g_conf->filestore_merge_threshold,
g_conf->filestore_split_multiple,
CollectionIndex::HASH_INDEX_TAG_2);
return index.init();
switch (version) {
case CollectionIndex::FLAT_INDEX_TAG: {
- *index = Index(new FlatIndex(path),
+ *index = Index(new FlatIndex(c, path),
RemoveOnDelete(c, this));
return 0;
}
case CollectionIndex::HASH_INDEX_TAG: // fall through
case CollectionIndex::HASH_INDEX_TAG_2: {
// Must be a HashIndex
- *index = Index(new HashIndex(path, g_conf->filestore_merge_threshold,
+ *index = Index(new HashIndex(c, path, g_conf->filestore_merge_threshold,
g_conf->filestore_split_multiple, version),
RemoveOnDelete(c, this));
return 0;
} else {
// No need to check
- *index = Index(new HashIndex(path, g_conf->filestore_merge_threshold,
+ *index = Index(new HashIndex(c, path, g_conf->filestore_merge_threshold,
g_conf->filestore_split_multiple,
CollectionIndex::HASH_INDEX_TAG_2),
RemoveOnDelete(c, this));
private:
string lfn_attribute;
+ coll_t collection;
public:
/// Constructor
LFNIndex(
+ coll_t collection,
const char *base_path, ///< [in] path to Index root
uint32_t index_version)
- : base_path(base_path), index_version(index_version) {
+ : base_path(base_path), index_version(index_version),
+ collection(collection) {
if (index_version == HASH_INDEX_TAG) {
lfn_attribute = LFN_ATTR;
} else {
}
}
+ coll_t coll() const { return collection; }
+
/// Virtual destructor
virtual ~LFNIndex() {}