diff --git a/internal/storage/utils.go b/internal/storage/utils.go index e5d43f98f1..f99595eea0 100644 --- a/internal/storage/utils.go +++ b/internal/storage/utils.go @@ -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{} diff --git a/internal/storage/utils_test.go b/internal/storage/utils_test.go index 5a0c2f47d1..3a438fda79 100644 --- a/internal/storage/utils_test.go +++ b/internal/storage/utils_test.go @@ -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) }