func MurmurHash2(data []byte) (h int32) {
	const (
		M = 0x5bd1e995
		R = 24
		// From https://github.com/apache/kafka/blob/0.10.1/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L342
		seed = int32(-1756908916)
	)

	var k int32

	h = seed ^ int32(len(data))

	// Mix 4 bytes at a time into the hash
	for l := len(data); l >= 4; l -= 4 {
		k = int32(data[0]) | int32(data[1])<<8 | int32(data[2])<<16 | int32(data[3])<<24
		k *= M
		k ^= int32(uint32(k) >> R) // To match Kafka Impl
		k *= M
		h *= M
		h ^= k
		data = data[4:]
	}

	// Handle the last few bytes of the input array
	switch len(data) {
	case 3:
		h ^= int32(data[2]) << 16
		fallthrough
	case 2:
		h ^= int32(data[1]) << 8
		fallthrough
	case 1:
		h ^= int32(data[0])
		h *= M
	}

	// Do a few final mixes of the hash to ensure the last few bytes are well incorporated
	h ^= int32(uint32(h) >> 13)
	h *= M
	h ^= int32(uint32(h) >> 15)

	return
}
// The original MurmurHash2 32-bit algorithm by Austin Appleby.
// Taken from https://github.com/aviddiviner/go-murmur by David Irvine
// Adapted to match the behavior of the Java Kafka Client
The original MurmurHash2 32-bit algorithm by Austin Appleby.
// The original MurmurHash2 32 - bit algorithm by Austin Appleby . // Taken from https : // github . com / aviddiviner / go - murmur by David Irvine // Adapted to match the behavior of the Java Kafka Client
func MurmurHash2(data []byte) (h int32) {
	const (
		M = 0x5bd1e995
		R = 24
		seed = int32(-1756908916)
	)
	var k int32
	h = seed ^ int32(len(data))
	for l := len(data); l >= 4; l -= 4 {
		k = int32(data[0]) | int32(data[1])<<8 | int32(data[2])<<16 | int32(data[3])<<24
		k *= M
		k ^= int32(uint32(k) >> R) 
		k *= M
		h *= M
		h ^= k
		data = data[4:]
	}
	switch len(data) {
	case 3:
		h ^= int32(data[2]) << 16
		fallthrough
	case 2:
		h ^= int32(data[1]) << 8
		fallthrough
	case 1:
		h ^= int32(data[0])
		h *= M
	}
	h ^= int32(uint32(h) >> 13)
	h *= M
	h ^= int32(uint32(h) >> 15)
	return
}
func MurmurHash2 ( data [ ] byte ) ( h int32 ) { const ( M = 0x5bd1e995 R = 24 seed = int32 ( - 1756908916 ) ) var k int32 h = seed ^ int32 ( len ( data ) ) for l := len ( data ) ; l >= 4 ; l -= 4 { k = int32 ( data [ 0 ] ) | int32 ( data [ 1 ] ) << 8 | int32 ( data [ 2 ] ) << 16 | int32 ( data [ 3 ] ) << 24 k *= M k ^= int32 ( uint32 ( k ) >> R ) k *= M h *= M h ^= k data = data [ 4 : ] } switch len ( data ) { case 3 : h ^= int32 ( data [ 2 ] ) << 16 fallthrough case 2 : h ^= int32 ( data [ 1 ] ) << 8 fallthrough case 1 : h ^= int32 ( data [ 0 ] ) h *= M } h ^= int32 ( uint32 ( h ) >> 13 ) h *= M h ^= int32 ( uint32 ( h ) >> 15 ) return }
The original MurmurHash2 32-bit algorithm by Austin Appleby.
The original MurmurHash2 32 - bit algorithm by Austin Appleby .
// From https://github.com/apache/kafka/blob/0.10.1/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L342 // Mix 4 bytes at a time into the hash // To match Kafka Impl // Handle the last few bytes of the input array // Do a few final mixes of the hash to ensure the last few bytes are well incorporated