hash.pxd 956 B

123456789101112131415161718192021222324252627282930313233
  1. from libc.stdint cimport uint32_t, uint64_t
  2. from lakesuperior.store.ldp_rs.term 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 = b'\xff\xf2Q\xf2j\x0bG\xc1\x8a}\xca\x92\x98^y\x12'
  10. cdef enum:
  11. HLEN_32 = sizeof(uint32_t)
  12. HLEN_64 = sizeof(uint64_t)
  13. HLEN_128 = sizeof(uint64_t) * 2
  14. ctypedef uint32_t Hash32
  15. ctypedef uint64_t Hash64
  16. ctypedef uint64_t DoubleHash64[2]
  17. ctypedef unsigned char Hash128[HLEN_128]
  18. cdef:
  19. uint32_t term_hash_seed32
  20. uint64_t term_hash_seed64_1, term_hash_seed64_2
  21. unsigned char TERM_HASH_SEED[16]
  22. int hash32(const Buffer *message, Hash32 *hash) except -1
  23. int hash64(const Buffer *message, Hash64 *hash) except -1
  24. int hash128(const Buffer *message, Hash128 *hash) except -1
  25. TERM_HASH_SEED = _TERM_HASH_SEED