proxygen
folly::IOBufHash Struct Reference

#include <IOBuf.h>

Public Member Functions

size_t operator() (const IOBuf &buf) const noexcept
 
size_t operator() (const std::unique_ptr< IOBuf > &buf) const noexcept
 
size_t operator() (const IOBuf *buf) const noexcept
 

Detailed Description

Hasher for IOBuf objects. Hashes the entire chain using SpookyHashV2.

Definition at line 1510 of file IOBuf.h.

Member Function Documentation

size_t folly::IOBufHash::operator() ( const IOBuf buf) const
noexcept

Definition at line 1090 of file IOBuf.cpp.

References b, folly::hash::SpookyHashV2::Final(), folly::hash::SpookyHashV2::Init(), folly::io::detail::CursorBase< Derived, BufType >::peekBytes(), folly::io::detail::CursorBase< Derived, BufType >::skip(), uint64_t, and folly::hash::SpookyHashV2::Update().

1090  {
1092  hasher.Init(0, 0);
1093  io::Cursor cursor(&buf);
1094  for (;;) {
1095  auto b = cursor.peekBytes();
1096  if (b.empty()) {
1097  break;
1098  }
1099  hasher.Update(b.data(), b.size());
1100  cursor.skip(b.size());
1101  }
1102  uint64_t h1;
1103  uint64_t h2;
1104  hasher.Final(&h1, &h2);
1105  return static_cast<std::size_t>(h1);
1106 }
char b
void Init(uint64_t seed1, uint64_t seed2)
void Final(uint64_t *hash1, uint64_t *hash2) const
void Update(const void *message, size_t length)
size_t folly::IOBufHash::operator() ( const std::unique_ptr< IOBuf > &  buf) const
inlinenoexcept

Definition at line 1512 of file IOBuf.h.

1512  {
1513  return operator()(buf.get());
1514  }
size_t operator()(const IOBuf &buf) const noexcept
Definition: IOBuf.cpp:1090
size_t folly::IOBufHash::operator() ( const IOBuf buf) const
inlinenoexcept

Definition at line 1515 of file IOBuf.h.

1515  {
1516  return buf ? (*this)(*buf) : 0;
1517  }

The documentation for this struct was generated from the following files: