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

Signed-off-by: dragondriver <jiquan.long@zilliz.com>
pull/9655/head
dragondriver 2021-10-11 18:20:30 +08:00 committed by GitHub
parent 7fbd0e9b50
commit 7daa319dc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -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{}

View File

@ -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)
}