mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
fix: Correct varchar primarykey size calculation (#37617)
See also: #37582 --------- Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
parent
cd181e4c6d
commit
31a8d08bdd
@ -39,8 +39,8 @@ func (s *DeltaBufferSuite) TestBuffer() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
memSize := deltaBuffer.Buffer(pks, tss, &msgpb.MsgPosition{Timestamp: 100}, &msgpb.MsgPosition{Timestamp: 200})
|
memSize := deltaBuffer.Buffer(pks, tss, &msgpb.MsgPosition{Timestamp: 100}, &msgpb.MsgPosition{Timestamp: 200})
|
||||||
// 40 = (3*8+8)(string pk) + 8(ts)
|
// 19 = (3+8)(string pk) + 8(ts)
|
||||||
s.EqualValues(100*40, memSize)
|
s.EqualValues(100*19, memSize)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ func (s *DoubleCacheBufferSuite) TestPut() {
|
|||||||
s.Equal(1, len(buffer.ListAfter(12)))
|
s.Equal(1, len(buffer.ListAfter(12)))
|
||||||
entryNum, memorySize := buffer.Size()
|
entryNum, memorySize := buffer.Size()
|
||||||
s.EqualValues(2, entryNum)
|
s.EqualValues(2, entryNum)
|
||||||
s.EqualValues(304, memorySize)
|
s.EqualValues(234, memorySize)
|
||||||
|
|
||||||
buffer.Put(&Item{
|
buffer.Put(&Item{
|
||||||
Ts: 13,
|
Ts: 13,
|
||||||
@ -133,7 +133,7 @@ func (s *DoubleCacheBufferSuite) TestPut() {
|
|||||||
s.Equal(1, len(buffer.ListAfter(13)))
|
s.Equal(1, len(buffer.ListAfter(13)))
|
||||||
entryNum, memorySize = buffer.Size()
|
entryNum, memorySize = buffer.Size()
|
||||||
s.EqualValues(2, entryNum)
|
s.EqualValues(2, entryNum)
|
||||||
s.EqualValues(304, memorySize)
|
s.EqualValues(234, memorySize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoubleCacheDeleteBuffer(t *testing.T) {
|
func TestDoubleCacheDeleteBuffer(t *testing.T) {
|
||||||
|
|||||||
@ -155,7 +155,6 @@ func (ip *Int64PrimaryKey) GetValue() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ip *Int64PrimaryKey) Size() int64 {
|
func (ip *Int64PrimaryKey) Size() int64 {
|
||||||
// 8 + reflect.ValueOf(Int64PrimaryKey).Type().Size()
|
|
||||||
return 16
|
return 16
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +255,7 @@ func (vcp *VarCharPrimaryKey) Type() schemapb.DataType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vcp *VarCharPrimaryKey) Size() int64 {
|
func (vcp *VarCharPrimaryKey) Size() int64 {
|
||||||
return int64(8*len(vcp.Value) + 8)
|
return int64(len(vcp.Value) + 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenPrimaryKeyByRawData(data interface{}, pkType schemapb.DataType) (PrimaryKey, error) {
|
func GenPrimaryKeyByRawData(data interface{}, pkType schemapb.DataType) (PrimaryKey, error) {
|
||||||
|
|||||||
@ -10,8 +10,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestVarCharPrimaryKey(t *testing.T) {
|
func TestVarCharPrimaryKey(t *testing.T) {
|
||||||
pk := NewVarCharPrimaryKey("milvus")
|
t.Run("size", func(t *testing.T) {
|
||||||
|
longString := "The High-Performance Vector Database Built for Scale"
|
||||||
|
pk := NewVarCharPrimaryKey(longString)
|
||||||
|
gotSize := pk.Size()
|
||||||
|
expectSize := len(longString) + 8
|
||||||
|
|
||||||
|
assert.EqualValues(t, expectSize, gotSize)
|
||||||
|
})
|
||||||
|
|
||||||
|
pk := NewVarCharPrimaryKey("milvus")
|
||||||
testPk := NewVarCharPrimaryKey("milvus")
|
testPk := NewVarCharPrimaryKey("milvus")
|
||||||
|
|
||||||
// test GE
|
// test GE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user