forked from hoangtq219/murmur3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmurmur3.go
71 lines (56 loc) · 1.48 KB
/
murmur3.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package murmur3
const (
CHUNK_SIZE = 16
c1 = -8663945395140668459
c2 = 5545529020109919103
HexDigits = "0123456789abcdef"
)
type MurmurByteBuffer struct {
buffer *ByteBuffer
bufferSize int
chunkSize int
}
func initMurmurByteBuffer(chunkSize int) *MurmurByteBuffer {
return &MurmurByteBuffer{
buffer: allocateByteBuffer(chunkSize + 7),
bufferSize: chunkSize,
chunkSize: chunkSize,
}
}
func (mBB *MurmurByteBuffer) positionFunc(limit int) {
mBB.buffer.position(limit)
}
func (mBB *MurmurByteBuffer) limitFunc(chunkSize int) {
mBB.buffer.limit(chunkSize)
}
func (mBB *MurmurByteBuffer) limit() int {
return mBB.buffer.Limit
}
func (mBB *MurmurByteBuffer) position() int {
return mBB.buffer.Position
}
func (mBB *MurmurByteBuffer) remaining() int {
return mBB.buffer.Limit - mBB.buffer.Position
}
// Puts a long into this sink.
func (mBB *MurmurByteBuffer) putLong(val int64) {
mBB.buffer.putLong(val)
}
func (mBB *MurmurByteBuffer) ix(nextPutIndex int) int {
return mBB.buffer.Offset + nextPutIndex
}
func (mBB *MurmurByteBuffer) nextPutIndex(var1 int) int {
return mBB.buffer.nextPutIndex(var1)
}
func (mBB *MurmurByteBuffer) putCharL(index int, val byte) {
mBB.buffer.putCharL(index, val)
}
func (mBB *MurmurByteBuffer) flip() {
mBB.buffer.flip()
}
func (mBB *MurmurByteBuffer) get(index int) byte {
return mBB.buffer.get(mBB.buffer.ix(mBB.buffer.checkIndex(index)))
}
func (mBB *MurmurByteBuffer) getLong() int64 {
return mBB.buffer.getLong()
}