mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: [cp24]Correct varchar primarykey size calculation (#37619)
See also: #37582 pr: #37617 --------- Signed-off-by: yangxuan <xuan.yang@zilliz.com>
This commit is contained in:
parent
28bcd85bd0
commit
d23da2db4f
@ -39,8 +39,8 @@ func (s *DeltaBufferSuite) TestBuffer() {
|
||||
})
|
||||
|
||||
memSize := deltaBuffer.Buffer(pks, tss, &msgpb.MsgPosition{Timestamp: 100}, &msgpb.MsgPosition{Timestamp: 200})
|
||||
// 40 = (3*8+8)(string pk) + 8(ts)
|
||||
s.EqualValues(100*40, memSize)
|
||||
// 19 = (3+8)(string pk) + 8(ts)
|
||||
s.EqualValues(100*19, memSize)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ func (s *DoubleCacheBufferSuite) TestPut() {
|
||||
s.Equal(1, len(buffer.ListAfter(12)))
|
||||
entryNum, memorySize := buffer.Size()
|
||||
s.EqualValues(2, entryNum)
|
||||
s.EqualValues(304, memorySize)
|
||||
s.EqualValues(234, memorySize)
|
||||
|
||||
buffer.Put(&Item{
|
||||
Ts: 13,
|
||||
@ -133,7 +133,7 @@ func (s *DoubleCacheBufferSuite) TestPut() {
|
||||
s.Equal(1, len(buffer.ListAfter(13)))
|
||||
entryNum, memorySize = buffer.Size()
|
||||
s.EqualValues(2, entryNum)
|
||||
s.EqualValues(304, memorySize)
|
||||
s.EqualValues(234, memorySize)
|
||||
}
|
||||
|
||||
func TestDoubleCacheDeleteBuffer(t *testing.T) {
|
||||
|
||||
@ -154,7 +154,6 @@ func (ip *Int64PrimaryKey) GetValue() interface{} {
|
||||
}
|
||||
|
||||
func (ip *Int64PrimaryKey) Size() int64 {
|
||||
// 8 + reflect.ValueOf(Int64PrimaryKey).Type().Size()
|
||||
return 16
|
||||
}
|
||||
|
||||
@ -255,7 +254,7 @@ func (vcp *VarCharPrimaryKey) Type() schemapb.DataType {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -10,8 +10,16 @@ import (
|
||||
)
|
||||
|
||||
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")
|
||||
|
||||
// test GE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user