From: Mike Ryan Date: Tue, 31 Jul 2012 21:21:43 +0000 (-0700) Subject: buffer: class for efficiently calculating CRC32 of >= 1 bufferlist X-Git-Tag: v0.53~180^2~1^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a0b04bcecf8dc055d647d8fd661b79c4381f9556;p=ceph.git buffer: class for efficiently calculating CRC32 of >= 1 bufferlist Signed-off-by: Mike Ryan --- diff --git a/src/include/buffer.h b/src/include/buffer.h index b2f1325eef71..f063c7ca64bc 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -427,10 +427,30 @@ public: } }; + + /* + * efficient hash of one or more bufferlists + */ + + class hash { + __u32 crc; + + public: + hash() : crc(0) { } + + void update(buffer::list& bl) { + crc = bl.crc32c(crc); + } + + __u32 digest() { + return crc; + } + }; }; typedef buffer::ptr bufferptr; typedef buffer::list bufferlist; +typedef buffer::hash bufferhash; inline bool operator>(bufferlist& l, bufferlist& r) { @@ -497,6 +517,11 @@ inline std::ostream& operator<<(std::ostream& out, buffer::error& e) return out << e.what(); } +inline bufferhash& operator<<(bufferhash& l, bufferlist &r) { + l.update(r); + return l; +} + } #endif