This commit is contained in:
Aliaksandr Valialkin 2024-06-03 14:01:05 +02:00
parent 5942d38742
commit 001f8969f8
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
4 changed files with 7 additions and 7 deletions

View file

@ -1226,7 +1226,7 @@ func (br *blockResult) getBucketedValue(s string, bf *byStatsField) string {
buf := br.a.b
bufLen := len(buf)
buf = marshalDuration(buf, nsecs)
buf = marshalDurationString(buf, nsecs)
br.a.b = buf
return bytesutil.ToUnsafeString(buf[bufLen:])
}

View file

@ -243,8 +243,8 @@ func (q *Query) String() string {
func (q *Query) AddCountByTimePipe(step, off int64, fields []string) {
{
// add 'stats by (_time:step offset off, fields) count() hits'
stepStr := string(marshalDuration(nil, step))
offsetStr := string(marshalDuration(nil, off))
stepStr := string(marshalDurationString(nil, step))
offsetStr := string(marshalDurationString(nil, off))
byFieldsStr := "_time:" + stepStr + " offset " + offsetStr
for _, f := range fields {
byFieldsStr += ", " + quoteTokenIfNeeded(f)

View file

@ -860,8 +860,8 @@ func tryParseDuration(s string) (int64, bool) {
return nsecs, true
}
// marshalDuration appends string representation of nsec duration to dst and returns the result.
func marshalDuration(dst []byte, nsecs int64) []byte {
// marshalDurationString appends string representation of nsec duration to dst and returns the result.
func marshalDurationString(dst []byte, nsecs int64) []byte {
if nsecs == 0 {
return append(dst, '0')
}

View file

@ -378,11 +378,11 @@ func TestTryParseDuration_Failure(t *testing.T) {
f("2s 3ms")
}
func TestMarshalDuration(t *testing.T) {
func TestMarshalDurationString(t *testing.T) {
f := func(nsecs int64, resultExpected string) {
t.Helper()
result := marshalDuration(nil, nsecs)
result := marshalDurationString(nil, nsecs)
if string(result) != resultExpected {
t.Fatalf("unexpected result; got %q; want %q", result, resultExpected)
}