From 1e7090cc8ea59f2b0f3dd5de2e3873894c6b4259 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 11 May 2024 01:34:41 +0200 Subject: [PATCH] wip --- lib/logstorage/values_encoder.go | 9 ++++++++- lib/logstorage/values_encoder_test.go | 12 ++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/logstorage/values_encoder.go b/lib/logstorage/values_encoder.go index de0a38dd5..131721b70 100644 --- a/lib/logstorage/values_encoder.go +++ b/lib/logstorage/values_encoder.go @@ -147,13 +147,20 @@ func (vd *valuesDecoder) decodeInplace(values []string, vt valueType, dictValues case valueTypeString: // nothing to do - values are already decoded. case valueTypeDict: + sb := getStringBucket() + for _, v := range dictValues { + dstLen := len(dstBuf) + dstBuf = append(dstBuf, v...) + sb.a = append(sb.a, bytesutil.ToUnsafeString(dstBuf[dstLen:])) + } for i, v := range values { id := int(v[0]) if id >= len(dictValues) { return fmt.Errorf("unexpected dictionary id: %d; it must be smaller than %d", id, len(dictValues)) } - values[i] = dictValues[id] + values[i] = sb.a[id] } + putStringBucket(sb) case valueTypeUint8: for i, v := range values { if len(v) != 1 { diff --git a/lib/logstorage/values_encoder_test.go b/lib/logstorage/values_encoder_test.go index 693d71495..e5b73b3c5 100644 --- a/lib/logstorage/values_encoder_test.go +++ b/lib/logstorage/values_encoder_test.go @@ -77,6 +77,12 @@ func TestValuesEncoder(t *testing.T) { } f(values, valueTypeUint64, 1<<32, uint64(len(values))<<32) + // float64 values + for i := range values { + values[i] = fmt.Sprintf("%g", math.Sqrt(float64(i+1))) + } + f(values, valueTypeFloat64, 4607182418800017408, 4613937818241073152) + // ipv4 values for i := range values { values[i] = fmt.Sprintf("1.2.3.%d", i) @@ -88,12 +94,6 @@ func TestValuesEncoder(t *testing.T) { values[i] = fmt.Sprintf("2011-04-19T03:44:01.%03dZ", i) } f(values, valueTypeTimestampISO8601, 1303184641000000000, 1303184641008000000) - - // float64 values - for i := range values { - values[i] = fmt.Sprintf("%g", math.Sqrt(float64(i+1))) - } - f(values, valueTypeFloat64, 4607182418800017408, 4613937818241073152) } func TestTryParseIPv4_Success(t *testing.T) {