From 001f8969f826157751d57918c6f36cdc0ca1cdfd Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 3 Jun 2024 14:01:05 +0200 Subject: [PATCH] wip --- lib/logstorage/block_result.go | 2 +- lib/logstorage/parser.go | 4 ++-- lib/logstorage/values_encoder.go | 4 ++-- lib/logstorage/values_encoder_test.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/logstorage/block_result.go b/lib/logstorage/block_result.go index 1f1d312d4..a4858f3ba 100644 --- a/lib/logstorage/block_result.go +++ b/lib/logstorage/block_result.go @@ -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:]) } diff --git a/lib/logstorage/parser.go b/lib/logstorage/parser.go index 87e4ecc00..37a962de5 100644 --- a/lib/logstorage/parser.go +++ b/lib/logstorage/parser.go @@ -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) diff --git a/lib/logstorage/values_encoder.go b/lib/logstorage/values_encoder.go index 56ac11381..f1a909279 100644 --- a/lib/logstorage/values_encoder.go +++ b/lib/logstorage/values_encoder.go @@ -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') } diff --git a/lib/logstorage/values_encoder_test.go b/lib/logstorage/values_encoder_test.go index f6d2d26da..369f12b06 100644 --- a/lib/logstorage/values_encoder_test.go +++ b/lib/logstorage/values_encoder_test.go @@ -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) }