mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
238115a6e7
commit
827984faa2
2 changed files with 18 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"math"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
@ -1933,7 +1934,7 @@ func tryParseNumber(s string) (float64, bool) {
|
|||
if ok {
|
||||
return float64(bytes), true
|
||||
}
|
||||
if isNumberPrefix(s) {
|
||||
if isLikelyNumber(s) {
|
||||
f, err := strconv.ParseFloat(s, 64)
|
||||
if err == nil {
|
||||
return f, true
|
||||
|
@ -1946,5 +1947,20 @@ func tryParseNumber(s string) (float64, bool) {
|
|||
return 0, false
|
||||
}
|
||||
|
||||
func isLikelyNumber(s string) bool {
|
||||
if !isNumberPrefix(s) {
|
||||
return false
|
||||
}
|
||||
if strings.Count(s, ".") > 1 {
|
||||
// This is likely IP address
|
||||
return false
|
||||
}
|
||||
if strings.IndexByte(s, ':') >= 0 || strings.Count(s, "-") > 2 {
|
||||
// This is likely a timestamp
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
var nan = math.NaN()
|
||||
var inf = math.Inf(1)
|
||||
|
|
|
@ -496,7 +496,7 @@ func TestParseRangeFilter(t *testing.T) {
|
|||
}
|
||||
fr, ok := q.f.(*filterRange)
|
||||
if !ok {
|
||||
t.Fatalf("unexpected filter type; got %T; want *filterIPv4Range; filter: %s", q.f, q.f)
|
||||
t.Fatalf("unexpected filter type; got %T; want *filterRange; filter: %s", q.f, q.f)
|
||||
}
|
||||
if fr.fieldName != fieldNameExpected {
|
||||
t.Fatalf("unexpected fieldName; got %q; want %q", fr.fieldName, fieldNameExpected)
|
||||
|
|
Loading…
Reference in a new issue