]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hobject_t: define explicit hash, operator<<; drop implicit sobject_t()
authorSage Weil <sage.weil@dreamhost.com>
Thu, 1 Dec 2011 18:58:37 +0000 (10:58 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Wed, 7 Dec 2011 19:40:10 +0000 (11:40 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/object.h

index be27b8b42ed980f89a8c854d6cfb58f299558f6b..1fbea7816ae4817e540c45066a04d40121929245 100644 (file)
@@ -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<hobject_t> {
-    size_t operator()(const sobject_t &r) const {
+    size_t operator()(const hobject_t &r) const {
       static hash<object_t> H;
       static rjhash<uint64_t> 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 <get_filestore_key,name,snapid>
 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;