proxygen
folly::detail::SlowFingerprint< BITS > Class Template Reference

#include <SlowFingerprint.h>

Public Member Functions

 SlowFingerprint ()
 
SlowFingerprintupdate8 (uint8_t v)
 
SlowFingerprintupdate32 (uint32_t v)
 
SlowFingerprintupdate64 (uint64_t v)
 
SlowFingerprintupdate (const folly::StringPiece str)
 
void write (uint64_t *out) const
 

Private Member Functions

void updateBit (bool bit)
 
void updateLSB (uint64_t val, int bits)
 

Private Attributes

const FingerprintPolynomial< BITS-1 > poly_
 
FingerprintPolynomial< BITS-1 > fp_
 

Detailed Description

template<int BITS>
class folly::detail::SlowFingerprint< BITS >

Slow, one-bit-at-a-time implementation of the Rabin fingerprint.

This is useful as a reference implementation to test the Broder optimization for correctness in the unittest; it's probably too slow for any real use.

Definition at line 33 of file SlowFingerprint.h.

Constructor & Destructor Documentation

template<int BITS>
folly::detail::SlowFingerprint< BITS >::SlowFingerprint ( )
inline

Definition at line 35 of file SlowFingerprint.h.

References folly::detail::FingerprintPolynomial< DEG >::addXk(), and folly::detail::SlowFingerprint< BITS >::fp_.

36  // Use the same starting value as Fingerprint, (1 << (BITS-1))
37  fp_.addXk(BITS - 1);
38  }
FingerprintPolynomial< BITS-1 > fp_
const uint64_t poly[poly_size(64)]
const FingerprintPolynomial< BITS-1 > poly_

Member Function Documentation

template<int BITS>
SlowFingerprint& folly::detail::SlowFingerprint< BITS >::update ( const folly::StringPiece  str)
inline

Definition at line 55 of file SlowFingerprint.h.

References i, folly::Range< Iter >::size(), folly::Range< Iter >::start(), and folly::detail::SlowFingerprint< BITS >::update8().

55  {
56  const char* p = str.start();
57  for (int i = str.size(); i != 0; p++, i--) {
58  update8(static_cast<uint8_t>(*p));
59  }
60  return *this;
61  }
constexpr size_type size() const
Definition: Range.h:431
constexpr Iter start() const
Definition: Range.h:449
SlowFingerprint & update8(uint8_t v)
template<int BITS>
SlowFingerprint& folly::detail::SlowFingerprint< BITS >::update32 ( uint32_t  v)
inline

Definition at line 45 of file SlowFingerprint.h.

References folly::detail::SlowFingerprint< BITS >::updateLSB().

45  {
46  updateLSB(v, 32);
47  return *this;
48  }
void updateLSB(uint64_t val, int bits)
template<int BITS>
SlowFingerprint& folly::detail::SlowFingerprint< BITS >::update64 ( uint64_t  v)
inline

Definition at line 50 of file SlowFingerprint.h.

References folly::detail::SlowFingerprint< BITS >::updateLSB().

Referenced by TEST().

50  {
51  updateLSB(v, 64);
52  return *this;
53  }
void updateLSB(uint64_t val, int bits)
template<int BITS>
SlowFingerprint& folly::detail::SlowFingerprint< BITS >::update8 ( uint8_t  v)
inline

Definition at line 40 of file SlowFingerprint.h.

References folly::detail::SlowFingerprint< BITS >::updateLSB().

Referenced by folly::detail::SlowFingerprint< BITS >::update().

40  {
41  updateLSB(v, 8);
42  return *this;
43  }
void updateLSB(uint64_t val, int bits)
template<int BITS>
void folly::detail::SlowFingerprint< BITS >::updateBit ( bool  bit)
inlineprivate
template<int BITS>
void folly::detail::SlowFingerprint< BITS >::updateLSB ( uint64_t  val,
int  bits 
)
inlineprivate

Definition at line 77 of file SlowFingerprint.h.

References folly::detail::SlowFingerprint< BITS >::updateBit().

Referenced by folly::detail::SlowFingerprint< BITS >::update32(), folly::detail::SlowFingerprint< BITS >::update64(), and folly::detail::SlowFingerprint< BITS >::update8().

77  {
78  val <<= (64 - bits);
79  for (; bits != 0; --bits) {
80  updateBit(val & (1ULL << 63));
81  val <<= 1;
82  }
83  }
double val
Definition: String.cpp:273
template<int BITS>
void folly::detail::SlowFingerprint< BITS >::write ( uint64_t out) const
inline

Definition at line 63 of file SlowFingerprint.h.

References folly::detail::SlowFingerprint< BITS >::fp_, folly::detail::FingerprintPolynomial< DEG >::get(), i, and folly::detail::FingerprintPolynomial< DEG >::size().

Referenced by TEST().

63  {
64  for (int i = 0; i < fp_.size(); ++i) {
65  out[i] = fp_.get(i);
66  }
67  }
FingerprintPolynomial< BITS-1 > fp_
constexpr uint64_t get(size_t i) const

Member Data Documentation

template<int BITS>
const FingerprintPolynomial<BITS - 1> folly::detail::SlowFingerprint< BITS >::poly_
private

Definition at line 85 of file SlowFingerprint.h.

Referenced by folly::detail::SlowFingerprint< BITS >::updateBit().


The documentation for this class was generated from the following file: