From 63e3d864306e1f95ca086cd338b5c7c95be8dfc1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 1 Dec 2011 10:58:37 -0800 Subject: [PATCH] hobject_t: define explicit hash, operator<<; drop implicit sobject_t() Signed-off-by: Sage Weil --- src/include/object.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/include/object.h b/src/include/object.h index be27b8b42ed98..1fbea7816ae48 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -289,6 +289,9 @@ public: h.max = true; return h; } + bool is_max() const { + return max; + } filestore_hobject_key_t get_filestore_key() const { uint32_t retval = hash; @@ -317,10 +320,6 @@ public: hash = temp.hash; } - operator sobject_t() const { - return sobject_t(oid, snap); - } - void encode(bufferlist& bl) const { __u8 version = 1; ::encode(version, bl); @@ -343,7 +342,7 @@ WRITE_CLASS_ENCODER(hobject_t) namespace __gnu_cxx { template<> struct hash { - size_t operator()(const sobject_t &r) const { + size_t operator()(const hobject_t &r) const { static hash H; static rjhash I; return H(r.oid) ^ I(r.snap); @@ -351,6 +350,16 @@ namespace __gnu_cxx { }; } +inline ostream& operator<<(ostream& out, const hobject_t& o) +{ + if (o.is_max()) + return out << "MAX"; + out << o.oid << "/" << o.snap << "/" << std::hex << o.hash << std::dec; + if (o.get_key().length()) + out << "@" << o.get_key(); + return out; +} + // sort hobject_t's by inline bool operator==(const hobject_t &l, const hobject_t &r) { return l.oid == r.oid && l.snap == r.snap && l.hash == r.hash && l.max == r.max; -- 2.39.5