github.com/m3db/stackmurmur3@v1.0.1/murmur.go (about) 1 // Copyright 2013, Sébastien Paolacci. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3. 7 8 Reference implementation: 9 http://code.google.com/p/smhasher/wiki/MurmurHash3 10 11 History, characteristics and (legacy) perfs: 12 https://sites.google.com/site/murmurhash/ 13 https://sites.google.com/site/murmurhash/statistics 14 */ 15 package murmur3 16 17 type digest struct { 18 clen int // Digested input cumulative length. 19 buf [16]byte // Expected (but not required) to be Size() large. 20 seed uint32 // Seed for initializing the hash. 21 tail int // Length used in buf to store tailing unprocessed bytes. 22 } 23 24 func (d digest) BlockSize() int { 25 return 1 26 } 27 28 func (d digest) loadUint32(idx int) uint32 { 29 b := idx * 4 30 return uint32(d.buf[b+0]) | uint32(d.buf[b+1])<<8 | uint32(d.buf[b+2])<<16 | uint32(d.buf[b+3])<<24 31 } 32 33 func (d digest) loadUint64(idx int) uint64 { 34 b := idx * 8 35 return uint64(d.buf[b+0]) | uint64(d.buf[b+1])<<8 | uint64(d.buf[b+2])<<16 | uint64(d.buf[b+3])<<24 | 36 uint64(d.buf[b+4])<<32 | uint64(d.buf[b+5])<<40 | uint64(d.buf[b+6])<<48 | uint64(d.buf[b+7])<<56 37 }