hash.pxd 977 B

12345678910111213141516171819202122232425262728293031323334
  1. from libc.stdint cimport uint32_t, uint64_t
  2. from lakesuperior.model.base cimport Buffer
  3. # Seed for computing the term hash.
  4. #
  5. # This is a 16-byte string that will be split up into two ``uint64``
  6. # numbers to make up the ``spookyhash_128`` seeds.
  7. #
  8. # TODO This should be made configurable.
  9. DEF _TERM_HASH_SEED = \
  10. b'\x72\x69\x76\x65\x72\x72\x75\x6e\x2c\x20\x70\x61\x73\x74\x20\x45'
  11. cdef enum:
  12. HLEN_32 = sizeof(uint32_t)
  13. HLEN_64 = sizeof(uint64_t)
  14. HLEN_128 = sizeof(uint64_t) * 2
  15. ctypedef uint32_t Hash32
  16. ctypedef uint64_t Hash64
  17. ctypedef uint64_t DoubleHash64[2]
  18. ctypedef unsigned char Hash128[HLEN_128]
  19. cdef:
  20. uint32_t term_hash_seed32
  21. uint64_t term_hash_seed64_1, term_hash_seed64_2
  22. unsigned char TERM_HASH_SEED[16]
  23. int hash32(const Buffer *message, Hash32 *hash) except -1
  24. int hash64(const Buffer *message, Hash64 *hash) except -1
  25. int hash128(const Buffer *message, Hash128 *hash) except -1
  26. TERM_HASH_SEED = _TERM_HASH_SEED