This commit is contained in:
Aliaksandr Valialkin 2024-05-11 01:34:41 +02:00
parent 3bc01a1ad6
commit 1e7090cc8e
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 14 additions and 7 deletions

View file

@ -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 {

View file

@ -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) {