未验证 提交 7daa319d 编写于 作者: D dragondriver 提交者: GitHub

[skip ci] Rename EstimateMemorySize to GetBinlogSize (#9651)

Signed-off-by: Ndragondriver <jiquan.long@zilliz.com>
上级 7fbd0e9b
......@@ -19,12 +19,12 @@ import (
"github.com/milvus-io/milvus/internal/kv"
)
// EstimateMemorySize get approximate memory size of a binlog file.
// GetBinlogSize get size of a binlog file.
// normal binlog file, error = nil;
// key not exist, size = 0, error = nil;
// key not in binlog format, size = (a not accurate number), error != nil;
// failed to read event reader, size = (a not accurate number), error != nil;
func EstimateMemorySize(kv kv.DataKV, key string) (int64, error) {
func GetBinlogSize(kv kv.DataKV, key string) (int64, error) {
total := int64(0)
header := &baseEventHeader{}
......
......@@ -135,17 +135,17 @@ func newMockWrongHeaderDataKV() kv.DataKV {
return &mockWrongHeaderDataKV{}
}
func TestEstimateMemorySize(t *testing.T) {
func TestGetBinlogSize(t *testing.T) {
memoryKV := memkv.NewMemoryKV()
defer memoryKV.Close()
key := "TestEstimateMemorySize"
key := "TestGetBinlogSize"
var size int64
var err error
// key not in memoryKV
size, err = EstimateMemorySize(memoryKV, key)
size, err = GetBinlogSize(memoryKV, key)
assert.NoError(t, err)
assert.Zero(t, size)
......@@ -185,28 +185,28 @@ func TestEstimateMemorySize(t *testing.T) {
err = memoryKV.Save(blob.Key, string(blob.Value))
assert.Nil(t, err)
size, err = EstimateMemorySize(memoryKV, blob.Key)
size, err = GetBinlogSize(memoryKV, blob.Key)
assert.Nil(t, err)
assert.Equal(t, size+int64(binary.Size(MagicNumber)), int64(len(blob.Value)))
}
}
// cover case that failed to read event header
func TestEstimateMemorySize_less_header(t *testing.T) {
func TestGetBinlogSize_less_header(t *testing.T) {
mockKV := newMockLessHeaderDataKV()
key := "TestEstimateMemorySize_less_header"
key := "TestGetBinlogSize_less_header"
_, err := EstimateMemorySize(mockKV, key)
_, err := GetBinlogSize(mockKV, key)
assert.Error(t, err)
}
// cover case that file not in binlog format
func TestEstimateMemorySize_not_in_binlog_format(t *testing.T) {
func TestGetBinlogSize_not_in_binlog_format(t *testing.T) {
mockKV := newMockWrongHeaderDataKV()
key := "TestEstimateMemorySize_not_in_binlog_format"
key := "TestGetBinlogSize_not_in_binlog_format"
_, err := EstimateMemorySize(mockKV, key)
_, err := GetBinlogSize(mockKV, key)
assert.Error(t, err)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册