mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-11 01:20:07 -04:00
* util/strutil: add Jaro-Winkler similarity implementation This is part of the implementation of prometheus/proposals#74 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * util/strutil: optimise JaroWinkler with string-native ASCII path Replace the generic jaroWinkler[T byte|rune] with two specialised functions: jaroWinklerString (ASCII path) operates directly on the string values and avoids the []byte conversion that previously caused two heap allocations per call; jaroWinklerRunes (Unicode path) is unchanged in algorithm but split out from the generic. Both paths replace the repeated float64 divisions in the Jaro formula with precomputed reciprocals (invL1, invL2). Result: short ASCII strings drop from 2 allocs/op to 0 allocs/op; long ASCII drops from 4 allocs/op to 2 allocs/op (bool match arrays only). Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * util/strutil: replace JaroWinkler with JaroWinklerMatcher Remove the free JaroWinkler function and replace it with a JaroWinklerMatcher struct. NewJaroWinklerMatcher pre-computes the ASCII check and rune conversion for the search term once; Score then runs the comparison against each candidate without repeating that work. This is the expected usage pattern in Prometheus: one fixed term scored against many label names or values. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> * Update util/strutil/jarowinkler.go and util/strutil/jarowinkler_test.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --------- Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Julien <291750+roidelapluie@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> |
||
|---|---|---|
| .. | ||
| almost | ||
| annotations | ||
| compression | ||
| convertnhcb | ||
| documentcli | ||
| features | ||
| fmtutil | ||
| fuzzing | ||
| gate | ||
| httputil | ||
| jsonutil | ||
| junitxml | ||
| kahansum | ||
| logging | ||
| namevalidationutil | ||
| netconnlimit | ||
| notifications | ||
| osutil | ||
| pool | ||
| runtime | ||
| runutil | ||
| stats | ||
| strutil | ||
| testrecord | ||
| teststorage | ||
| testutil | ||
| testwal | ||
| treecache | ||
| zeropool | ||