/
ops_builtin.go
164 lines (143 loc) · 3.83 KB
/
ops_builtin.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT.
package frame
import (
"math"
"github.com/spaolacci/murmur3"
)
func init() {
RegisterOps(func(slice []string) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return murmur3.Sum32WithSeed([]byte(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uint) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(uint64(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uint8) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uint16) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uint32) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uint64) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(uint64(slice[i]), seed)
},
}
})
RegisterOps(func(slice []int) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(uint64(slice[i]), seed)
},
}
})
RegisterOps(func(slice []int8) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []int16) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []int32) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(uint32(slice[i]), seed)
},
}
})
RegisterOps(func(slice []int64) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(uint64(slice[i]), seed)
},
}
})
RegisterOps(func(slice []float32) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash32(math.Float32bits(slice[i]), seed)
},
}
})
RegisterOps(func(slice []float64) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(math.Float64bits(slice[i]), seed)
},
}
})
RegisterOps(func(slice []uintptr) Ops {
return Ops{
Less: func(i, j int) bool { return slice[i] < slice[j] },
HashWithSeed: func(i int, seed uint32) uint32 {
return hash64(uint64(slice[i]), seed)
},
}
})
}
// Hash32 is the 32-bit integer hashing function from
// http://burtleburtle.net/bob/hash/integer.html. (Public domain.)
func hash32(x, seed uint32) uint32 {
var b [4]byte
b[0] = byte(x)
b[1] = byte(x >> 8)
b[2] = byte(x >> 16)
b[3] = byte(x >> 24)
return murmur3.Sum32WithSeed(b[:], seed)
}
// Hash64 uses hash32 to compute a 64-bit integer hash.
func hash64(x uint64, seed uint32) uint32 {
var b [8]byte
b[0] = byte(x)
b[1] = byte(x >> 8)
b[2] = byte(x >> 16)
b[3] = byte(x >> 24)
b[4] = byte(x >> 32)
b[5] = byte(x >> 40)
b[6] = byte(x >> 48)
b[7] = byte(x >> 56)
return murmur3.Sum32WithSeed(b[:], seed)
}