mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
fix: Make fp16&bf16 column use correct byte length (#33684)
See also milvus-io/milvus-sdk-go#756 #31293 Signed-off-by: Congqi Xia <congqi.xia@zilliz.com> Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
6ce9df913f
commit
60baaed832
@ -281,12 +281,12 @@ func FieldDataColumn(fd *schemapb.FieldData, begin, end int) (Column, error) {
|
||||
data := x.Float16Vector
|
||||
dim := int(vectors.GetDim())
|
||||
if end < 0 {
|
||||
end = len(data) / dim
|
||||
end = len(data) / dim / 2
|
||||
}
|
||||
vector := make([][]byte, 0, end-begin)
|
||||
for i := begin; i < end; i++ {
|
||||
v := make([]byte, dim)
|
||||
copy(v, data[i*dim:(i+1)*dim])
|
||||
v := make([]byte, dim*2)
|
||||
copy(v, data[i*dim*2:(i+1)*dim*2])
|
||||
vector = append(vector, v)
|
||||
}
|
||||
return NewColumnFloat16Vector(fd.GetFieldName(), dim, vector), nil
|
||||
@ -300,12 +300,12 @@ func FieldDataColumn(fd *schemapb.FieldData, begin, end int) (Column, error) {
|
||||
data := x.Bfloat16Vector
|
||||
dim := int(vectors.GetDim())
|
||||
if end < 0 {
|
||||
end = len(data) / dim
|
||||
end = len(data) / dim / 2
|
||||
}
|
||||
vector := make([][]byte, 0, end-begin) // shall not have remanunt
|
||||
for i := begin; i < end; i++ {
|
||||
v := make([]byte, dim)
|
||||
copy(v, data[i*dim:(i+1)*dim])
|
||||
copy(v, data[i*dim*2:(i+1)*dim*2])
|
||||
vector = append(vector, v)
|
||||
}
|
||||
return NewColumnBFloat16Vector(fd.GetFieldName(), dim, vector), nil
|
||||
|
@ -39,14 +39,13 @@ func TestIDColumns(t *testing.T) {
|
||||
)
|
||||
|
||||
t.Run("nil id", func(t *testing.T) {
|
||||
col, err := IDColumns(intPKCol, nil, 0, -1)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, col.Len())
|
||||
col, err = IDColumns(strPKCol, nil, 0, -1)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, col.Len())
|
||||
_, err := IDColumns(intPKCol, nil, 0, -1)
|
||||
assert.Error(t, err)
|
||||
_, err = IDColumns(strPKCol, nil, 0, -1)
|
||||
assert.Error(t, err)
|
||||
|
||||
idField := &schemapb.IDs{}
|
||||
col, err = IDColumns(intPKCol, idField, 0, -1)
|
||||
col, err := IDColumns(intPKCol, idField, 0, -1)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 0, col.Len())
|
||||
col, err = IDColumns(strPKCol, idField, 0, -1)
|
||||
|
@ -244,7 +244,7 @@ func (c *ColumnFloat16Vector) FieldData() *schemapb.FieldData {
|
||||
FieldName: c.name,
|
||||
}
|
||||
|
||||
data := make([]byte, 0, len(c.values)*c.dim)
|
||||
data := make([]byte, 0, len(c.values)*c.dim*2)
|
||||
|
||||
for _, vector := range c.values {
|
||||
data = append(data, vector...)
|
||||
@ -330,7 +330,7 @@ func (c *ColumnBFloat16Vector) FieldData() *schemapb.FieldData {
|
||||
FieldName: c.name,
|
||||
}
|
||||
|
||||
data := make([]byte, 0, len(c.values)*c.dim)
|
||||
data := make([]byte, 0, len(c.values)*c.dim*2)
|
||||
|
||||
for _, vector := range c.values {
|
||||
data = append(data, vector...)
|
||||
|
Loading…
Reference in New Issue
Block a user