fix: [StorageV2] sync with int8 vector data type core dumped (#42616)

related: https://github.com/milvus-io/milvus/issues/42613, #39173

Signed-off-by: shaoting-huang <shaoting.huang@zilliz.com>
This commit is contained in:
sthuang 2025-06-10 11:42:35 +08:00 committed by GitHub
parent e19c22d77f
commit 9439eaef52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -459,7 +459,22 @@ var serdeMap = func() map[schemapb.DataType]serdeEntry {
} }
return nil, false return nil, false
}, },
fixedSizeSerializer, func(b array.Builder, v any) bool {
if v == nil {
b.AppendNull()
return true
}
if builder, ok := b.(*array.FixedSizeBinaryBuilder); ok {
if vv, ok := v.([]byte); ok {
builder.Append(vv)
return true
} else if vv, ok := v.([]int8); ok {
builder.Append(arrow.Int8Traits.CastToBytes(vv))
return true
}
}
return false
},
} }
m[schemapb.DataType_FloatVector] = serdeEntry{ m[schemapb.DataType_FloatVector] = serdeEntry{
func(i int) arrow.DataType { func(i int) arrow.DataType {

View File

@ -99,6 +99,7 @@ func TestSerDe(t *testing.T) {
{"test bfloat16 vector", args{dt: schemapb.DataType_BFloat16Vector, v: []byte{0xff, 0xff}}, []byte{0xff, 0xff}, true}, {"test bfloat16 vector", args{dt: schemapb.DataType_BFloat16Vector, v: []byte{0xff, 0xff}}, []byte{0xff, 0xff}, true},
{"test bfloat16 vector null", args{dt: schemapb.DataType_BFloat16Vector, v: nil}, nil, true}, {"test bfloat16 vector null", args{dt: schemapb.DataType_BFloat16Vector, v: nil}, nil, true},
{"test bfloat16 vector negative", args{dt: schemapb.DataType_BFloat16Vector, v: -1}, nil, false}, {"test bfloat16 vector negative", args{dt: schemapb.DataType_BFloat16Vector, v: -1}, nil, false},
{"test int8 vector", args{dt: schemapb.DataType_Int8Vector, v: []int8{10}}, []int8{10}, true},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {