From d43d1f750c3d01445a0b8b273ce26ba1af94fc5f Mon Sep 17 00:00:00 2001 From: ThyeeZz Date: Mon, 17 Jan 2022 11:04:11 +0800 Subject: [PATCH 1/4] fix unit error --- client/src/utils/SizingTool.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/utils/SizingTool.ts b/client/src/utils/SizingTool.ts index 4e82501b..a676c931 100644 --- a/client/src/utils/SizingTool.ts +++ b/client/src/utils/SizingTool.ts @@ -123,7 +123,9 @@ export const formatSize = (size: number) => { size = size / 1024; sizeStatus++; } - sizeStatus === 2 + sizeStatus === 1 + ? (status = 'B') + : sizeStatus === 2 ? (status = 'KB') : sizeStatus === 3 ? (status = 'MB') From 4c633780af443896c2e466c53da8635918f2c4d8 Mon Sep 17 00:00:00 2001 From: ThyeeZz Date: Mon, 17 Jan 2022 15:50:46 +0800 Subject: [PATCH 2/4] use enum to defined size status --- client/src/pages/schema/Types.ts | 8 ++++++++ client/src/utils/SizingTool.ts | 14 ++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/client/src/pages/schema/Types.ts b/client/src/pages/schema/Types.ts index cede15aa..f75af504 100644 --- a/client/src/pages/schema/Types.ts +++ b/client/src/pages/schema/Types.ts @@ -85,3 +85,11 @@ export interface SizingInfoParam { disk: string; } | null; } + +export enum SIZE_STATUS { + 'B', + 'KB', + 'MB', + 'GB', + 'TB', +} diff --git a/client/src/utils/SizingTool.ts b/client/src/utils/SizingTool.ts index a676c931..7d1e9e28 100644 --- a/client/src/utils/SizingTool.ts +++ b/client/src/utils/SizingTool.ts @@ -1,4 +1,4 @@ -import { INDEX_TYPES_ENUM } from '../pages/schema/Types'; +import { INDEX_TYPES_ENUM, SIZE_STATUS } from '../pages/schema/Types'; const commonValueCalculator = ( vector: number, @@ -123,17 +123,7 @@ export const formatSize = (size: number) => { size = size / 1024; sizeStatus++; } - sizeStatus === 1 - ? (status = 'B') - : sizeStatus === 2 - ? (status = 'KB') - : sizeStatus === 3 - ? (status = 'MB') - : sizeStatus === 4 - ? (status = 'GB') - : sizeStatus === 5 - ? (status = 'TB') - : (status = 'KB'); + status = SIZE_STATUS[sizeStatus] ?? 'KB'; size = Math.ceil(size); From 2d4a6577d9454ab6ac215473ea2744a98efb51d5 Mon Sep 17 00:00:00 2001 From: ThyeeZz Date: Mon, 17 Jan 2022 16:08:06 +0800 Subject: [PATCH 3/4] add comment --- client/src/pages/schema/Types.ts | 10 +++++----- client/src/utils/SizingTool.ts | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/pages/schema/Types.ts b/client/src/pages/schema/Types.ts index f75af504..ed545852 100644 --- a/client/src/pages/schema/Types.ts +++ b/client/src/pages/schema/Types.ts @@ -87,9 +87,9 @@ export interface SizingInfoParam { } export enum SIZE_STATUS { - 'B', - 'KB', - 'MB', - 'GB', - 'TB', + 'B' = 1, + 'KB' = 2, + 'MB' = 3, + 'GB' = 4, + 'TB' = 5, } diff --git a/client/src/utils/SizingTool.ts b/client/src/utils/SizingTool.ts index 7d1e9e28..89bfbd36 100644 --- a/client/src/utils/SizingTool.ts +++ b/client/src/utils/SizingTool.ts @@ -117,6 +117,7 @@ export const computMilvusRecommonds = ( }; export const formatSize = (size: number) => { + // 1:B, 2:KB, 3:MB, 4:GB, 5:TB let sizeStatus = 1; let status = 'BYTE'; while (sizeStatus < 4 && size > 4096) { From c94268b831a7106cee24c62032b696d7a58194db Mon Sep 17 00:00:00 2001 From: ThyeeZz Date: Mon, 17 Jan 2022 16:24:37 +0800 Subject: [PATCH 4/4] update --- client/src/utils/SizingTool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/utils/SizingTool.ts b/client/src/utils/SizingTool.ts index 89bfbd36..bb66ff49 100644 --- a/client/src/utils/SizingTool.ts +++ b/client/src/utils/SizingTool.ts @@ -120,7 +120,7 @@ export const formatSize = (size: number) => { // 1:B, 2:KB, 3:MB, 4:GB, 5:TB let sizeStatus = 1; let status = 'BYTE'; - while (sizeStatus < 4 && size > 4096) { + while (sizeStatus < 4 && size > 1024) { size = size / 1024; sizeStatus++; }