mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
* Add redis support for distributed caching * Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * ... and another all nighter. * fixup! ... and another all nighter. * fixup! fixup! ... and another all nighter. * fixup! fixup! fixup! ... and another all nighter. * Resolve issue #85 by adding ability to set custom claims in JWT tokens * Remove redundant validation in auth middleware ( issue #89 ) * Add ability to set cookie prefix for session cookies ( #87 ) * fixup! Add ability to set cookie prefix for session cookies ( #87 ) * Add ability to set cookie max age - issue #91 * Potential fix for code scanning alert no. 10: Size computation for allocation may overflow Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fixup! Merge main into 0.8.0-redis: resolve conflicts --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
package hyperloglog
|
|
|
|
import (
|
|
"github.com/alicebob/miniredis/v2/metro"
|
|
"math"
|
|
"math/bits"
|
|
)
|
|
|
|
var hash = hashFunc
|
|
|
|
func beta14(ez float64) float64 {
|
|
zl := math.Log(ez + 1)
|
|
return -0.370393911*ez +
|
|
0.070471823*zl +
|
|
0.17393686*math.Pow(zl, 2) +
|
|
0.16339839*math.Pow(zl, 3) +
|
|
-0.09237745*math.Pow(zl, 4) +
|
|
0.03738027*math.Pow(zl, 5) +
|
|
-0.005384159*math.Pow(zl, 6) +
|
|
0.00042419*math.Pow(zl, 7)
|
|
}
|
|
|
|
func beta16(ez float64) float64 {
|
|
zl := math.Log(ez + 1)
|
|
return -0.37331876643753059*ez +
|
|
-1.41704077448122989*zl +
|
|
0.40729184796612533*math.Pow(zl, 2) +
|
|
1.56152033906584164*math.Pow(zl, 3) +
|
|
-0.99242233534286128*math.Pow(zl, 4) +
|
|
0.26064681399483092*math.Pow(zl, 5) +
|
|
-0.03053811369682807*math.Pow(zl, 6) +
|
|
0.00155770210179105*math.Pow(zl, 7)
|
|
}
|
|
|
|
func alpha(m float64) float64 {
|
|
switch m {
|
|
case 16:
|
|
return 0.673
|
|
case 32:
|
|
return 0.697
|
|
case 64:
|
|
return 0.709
|
|
}
|
|
return 0.7213 / (1 + 1.079/m)
|
|
}
|
|
|
|
func getPosVal(x uint64, p uint8) (uint64, uint8) {
|
|
i := bextr(x, 64-p, p) // {x63,...,x64-p}
|
|
w := x<<p | 1<<(p-1) // {x63-p,...,x0}
|
|
rho := uint8(bits.LeadingZeros64(w)) + 1
|
|
return i, rho
|
|
}
|
|
|
|
func linearCount(m uint32, v uint32) float64 {
|
|
fm := float64(m)
|
|
return fm * math.Log(fm/float64(v))
|
|
}
|
|
|
|
func bextr(v uint64, start, length uint8) uint64 {
|
|
return (v >> start) & ((1 << length) - 1)
|
|
}
|
|
|
|
func bextr32(v uint32, start, length uint8) uint32 {
|
|
return (v >> start) & ((1 << length) - 1)
|
|
}
|
|
|
|
func hashFunc(e []byte) uint64 {
|
|
return metro.Hash64(e, 1337)
|
|
}
|