Browse Source

remove unused code and components

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 year ago
parent
commit
0ad056744f

+ 17 - 0
client/src/components/icons/Icons.tsx

@@ -680,6 +680,23 @@ const icons: { [x in IconsType]: (props?: any) => React.ReactElement } = {
       ></path>
     </SvgIcon>
   ),
+  question: (props = {}) => (
+    <SvgIcon
+      width="15"
+      height="15"
+      viewBox="0 0 15 15"
+      fill="none"
+      xmlns="http://www.w3.org/2000/svg"
+      {...props}
+    >
+      <path
+        d="M0.877075 7.49972C0.877075 3.84204 3.84222 0.876892 7.49991 0.876892C11.1576 0.876892 14.1227 3.84204 14.1227 7.49972C14.1227 11.1574 11.1576 14.1226 7.49991 14.1226C3.84222 14.1226 0.877075 11.1574 0.877075 7.49972ZM7.49991 1.82689C4.36689 1.82689 1.82708 4.36671 1.82708 7.49972C1.82708 10.6327 4.36689 13.1726 7.49991 13.1726C10.6329 13.1726 13.1727 10.6327 13.1727 7.49972C13.1727 4.36671 10.6329 1.82689 7.49991 1.82689ZM8.24993 10.5C8.24993 10.9142 7.91414 11.25 7.49993 11.25C7.08571 11.25 6.74993 10.9142 6.74993 10.5C6.74993 10.0858 7.08571 9.75 7.49993 9.75C7.91414 9.75 8.24993 10.0858 8.24993 10.5ZM6.05003 6.25C6.05003 5.57211 6.63511 4.925 7.50003 4.925C8.36496 4.925 8.95003 5.57211 8.95003 6.25C8.95003 6.74118 8.68002 6.99212 8.21447 7.27494C8.16251 7.30651 8.10258 7.34131 8.03847 7.37854L8.03841 7.37858C7.85521 7.48497 7.63788 7.61119 7.47449 7.73849C7.23214 7.92732 6.95003 8.23198 6.95003 8.7C6.95004 9.00376 7.19628 9.25 7.50004 9.25C7.8024 9.25 8.04778 9.00601 8.05002 8.70417L8.05056 8.7033C8.05924 8.6896 8.08493 8.65735 8.15058 8.6062C8.25207 8.52712 8.36508 8.46163 8.51567 8.37436L8.51571 8.37433C8.59422 8.32883 8.68296 8.27741 8.78559 8.21506C9.32004 7.89038 10.05 7.35382 10.05 6.25C10.05 4.92789 8.93511 3.825 7.50003 3.825C6.06496 3.825 4.95003 4.92789 4.95003 6.25C4.95003 6.55376 5.19628 6.8 5.50003 6.8C5.80379 6.8 6.05003 6.55376 6.05003 6.25Z"
+        fill="currentColor"
+        fillRule="evenodd"
+        clipRule="evenodd"
+      ></path>
+    </SvgIcon>
+  ),
 };
 
 export default icons;

+ 2 - 1
client/src/components/icons/Types.ts

@@ -45,4 +45,5 @@ export type IconsType =
   | 'next'
   | 'prev'
   | 'expand'
-  | 'github';
+  | 'github'
+  | 'question';

+ 4 - 4
client/src/pages/collections/Collections.tsx

@@ -39,7 +39,7 @@ const useStyles = makeStyles((theme: Theme) => ({
   },
 
   icon: {
-    fontSize: '20px',
+    fontSize: '14px',
     marginLeft: theme.spacing(0.5),
   },
 
@@ -91,7 +91,7 @@ const Collections = () => {
 
   const classes = useStyles();
 
-  const InfoIcon = icons.info;
+  const QuestionIcon = icons.question;
   const SourceIcon = icons.source;
 
   const consistencyTooltipsMap: Record<string, string> = {
@@ -506,7 +506,7 @@ const Collections = () => {
         <span className="flex-center with-max-content">
           {collectionTrans('rowCount')}
           <CustomToolTip title={collectionTrans('entityCountInfo')}>
-            <InfoIcon width={15} classes={{ root: classes.icon }} />
+            <QuestionIcon classes={{ root: classes.icon }} />
           </CustomToolTip>
         </span>
       ),
@@ -582,7 +582,7 @@ const Collections = () => {
         <span className="flex-center with-max-content">
           {collectionTrans('alias')}
           <CustomToolTip title={collectionTrans('aliasInfo')}>
-            <InfoIcon width={15} classes={{ root: classes.icon }} />
+            <QuestionIcon classes={{ root: classes.icon }} />
           </CustomToolTip>
         </span>
       ),

+ 0 - 1
client/src/pages/collections/CreateFields.tsx

@@ -125,7 +125,6 @@ const CreateFields: FC<CreateFieldsProps> = ({
 
   const AddIcon = icons.addOutline;
   const RemoveIcon = icons.remove;
-  const InfoIcon = icons.info;
 
   const { requiredFields, optionalFields } = useMemo(
     () =>

+ 4 - 4
client/src/pages/dialogs/LoadCollectionDialog.tsx

@@ -31,7 +31,7 @@ const useStyles = makeStyles((theme: Theme) => ({
     marginBottom: theme.spacing(2),
   },
   icon: {
-    fontSize: '20px',
+    fontSize: '14px',
     marginLeft: theme.spacing(0.5),
   },
 }));
@@ -160,7 +160,7 @@ const LoadCollectionDialog = (props: any) => {
     }
   };
 
-  const InfoIcon = icons.info;
+  const QuestionIcon = icons.question;
 
   return (
     <DialogTemplate
@@ -173,7 +173,7 @@ const LoadCollectionDialog = (props: any) => {
           <Typography variant="body1" component="p" className={classes.desc}>
             {collectionTrans('loadContent')}
           </Typography>
-          {enableRelica ? (
+          {!enableRelica ? (
             <>
               <FormControlLabel
                 control={
@@ -183,7 +183,7 @@ const LoadCollectionDialog = (props: any) => {
                   <CustomToolTip title={collectionTrans('replicaDes')}>
                     <>
                       {collectionTrans('enableRepica')}
-                      <InfoIcon classes={{ root: classes.icon }} />
+                      <QuestionIcon classes={{ root: classes.icon }} />
                     </>
                   </CustomToolTip>
                 }

+ 3 - 3
client/src/pages/partitions/Partitions.tsx

@@ -22,7 +22,7 @@ const useStyles = makeStyles((theme: Theme) => ({
     height: `100%`,
   },
   icon: {
-    fontSize: '20px',
+    fontSize: '14px',
     marginLeft: theme.spacing(0.5),
   },
   highlight: {
@@ -43,7 +43,7 @@ const Partitions = () => {
   const [search, setSearch] = useState<string>(
     (searchParams.get('search') as string) || ''
   );
-  const InfoIcon = icons.info;
+  const QuestionIcon = icons.question;
 
   const { handleInsertDialog } = useInsertDialogHook();
 
@@ -232,7 +232,7 @@ const Partitions = () => {
         <span className="flex-center with-max-content">
           {t('rowCount')}
           <CustomToolTip title={t('tooltip')}>
-            <InfoIcon classes={{ root: classes.icon }} />
+            <QuestionIcon classes={{ root: classes.icon }} />
           </CustomToolTip>
         </span>
       ),

+ 1 - 63
client/src/pages/schema/Create.tsx

@@ -4,8 +4,6 @@ import { CodeLanguageEnum, CodeViewData } from '@/components/code/Types';
 import DialogTemplate from '@/components/customDialog/DialogTemplate';
 import CustomSwitch from '@/components/customSwitch/CustomSwitch';
 import {
-  DEFAULT_SEFMENT_FILE_SIZE,
-  DEFAULT_VECTORS,
   INDEX_CONFIG,
   INDEX_OPTIONS_MAP,
   METRIC_TYPES_VALUES,
@@ -17,14 +15,8 @@ import { useFormValidation } from '@/hooks';
 import { getCreateIndexJSCode } from '@/utils/code/Js';
 import { getCreateIndexPYCode } from '@/utils/code/Py';
 import { getCreateIndexJavaCode } from '@/utils/code/Java';
-import {
-  formatForm,
-  getMetricOptions,
-  computMilvusRecommonds,
-  formatSize,
-} from '@/utils';
+import { formatForm, getMetricOptions } from '@/utils';
 import CreateForm from './CreateForm';
-import SizingInfo from './SizingInfo';
 import { IndexType, IndexExtraParam } from './Types';
 
 const CreateIndex = (props: {
@@ -166,58 +158,6 @@ const CreateIndex = (props: {
     return form;
   }, [indexSetting, indexCreateParams, fieldType]);
 
-  // sizing info needed param
-  const sizingInfo = useMemo(() => {
-    const { index_type } = indexSetting;
-    const { nlist, m } = indexSetting;
-    const floatTypes = [
-      INDEX_TYPES_ENUM.IVF_FLAT,
-      INDEX_TYPES_ENUM.IVF_PQ,
-      INDEX_TYPES_ENUM.IVF_SQ8,
-      INDEX_TYPES_ENUM.IVF_SQ8_HYBRID,
-      INDEX_TYPES_ENUM.FLAT,
-    ];
-    const bytesTyps = [
-      INDEX_TYPES_ENUM.BIN_FLAT,
-      INDEX_TYPES_ENUM.BIN_IVF_FLAT,
-    ];
-    const supportedTypes = [...floatTypes, ...bytesTyps];
-    // check param validation
-    if (!supportedTypes.includes(index_type)) {
-      return null;
-    }
-
-    if (!nlist) {
-      return null;
-    }
-    if (index_type === INDEX_TYPES_ENUM.IVF_PQ && !m) {
-      return null;
-    }
-    // vector 100000, segment file size 1024 as default value
-    const milvusRecommends = computMilvusRecommonds(
-      DEFAULT_VECTORS,
-      dimension,
-      Number(nlist),
-      Number(m),
-      DEFAULT_SEFMENT_FILE_SIZE * 1024 * 1024
-    );
-
-    let memoryType = 'byteMemorySize';
-    let diskType = 'byteDiskSize';
-    if (floatTypes.includes(index_type)) {
-      memoryType = 'memorySize';
-      diskType = 'diskSize';
-    }
-
-    const memorySize = milvusRecommends[memoryType][index_type];
-    const diskSize = milvusRecommends[diskType][index_type];
-
-    return {
-      memory: formatSize(memorySize),
-      disk: formatSize(diskSize),
-    };
-  }, [dimension, indexSetting]);
-
   /**
    * create index code mode
    */
@@ -337,8 +277,6 @@ const CreateIndex = (props: {
           indexParams={indexCreateParams}
           indexTypeChange={onIndexTypeChange}
         />
-
-        <SizingInfo info={sizingInfo} />
       </>
     </DialogTemplate>
   );

+ 0 - 72
client/src/pages/schema/SizingInfo.tsx

@@ -1,72 +0,0 @@
-import { makeStyles, Theme, Typography } from '@material-ui/core';
-import { FC } from 'react';
-import { useTranslation } from 'react-i18next';
-import CustomToolTip from '@/components/customToolTip/CustomToolTip';
-import icons from '@/components/icons/Icons';
-import { SizingInfoParam } from './Types';
-
-const useStyles = makeStyles((theme: Theme) => ({
-  wrapper: {
-    display: 'flex',
-    alignItems: 'flex-start',
-    justifyContent: 'space-between',
-  },
-  header: {
-    display: 'flex',
-
-    '& .title': {
-      color: theme.palette.attuGrey.dark,
-    },
-  },
-  icon: {
-    fontSize: '20px',
-    marginLeft: theme.spacing(1),
-  },
-  info: {
-    display: 'flex',
-    flexDirection: 'column',
-    alignItems: 'flex-end',
-  },
-  pair: {
-    display: 'flex',
-
-    '& .key': {
-      marginRight: theme.spacing(2),
-      color: theme.palette.attuGrey.dark,
-    },
-  },
-}));
-
-const SizingInfo: FC<SizingInfoParam> = props => {
-  const { info } = props;
-  const { t: commonTrans } = useTranslation();
-  const InfoIcon = icons.info;
-
-  const classes = useStyles();
-
-  return (
-    info && (
-      <section className={classes.wrapper}>
-        <div className={classes.header}>
-          <Typography className="title">{commonTrans('size')}</Typography>
-          <CustomToolTip title={commonTrans('tip')} placement="top">
-            <InfoIcon classes={{ root: classes.icon }} />
-          </CustomToolTip>
-        </div>
-
-        <div className={classes.info}>
-          <div className={classes.pair}>
-            <Typography className="key">{commonTrans('memory')}</Typography>
-            <Typography>{info.memory}</Typography>
-          </div>
-          <div className={classes.pair}>
-            <Typography className="key">{commonTrans('disk')}</Typography>
-            <Typography>{info.disk}</Typography>
-          </div>
-        </div>
-      </section>
-    )
-  );
-};
-
-export default SizingInfo;

+ 0 - 15
client/src/pages/schema/Types.ts

@@ -35,18 +35,3 @@ export interface IndexExtraParam {
   metric_type: string;
   params: string;
 }
-
-export interface SizingInfoParam {
-  info: {
-    memory: string;
-    disk: string;
-  } | null;
-}
-
-export enum SIZE_STATUS {
-  'B' = 1,
-  'KB' = 2,
-  'MB' = 3,
-  'GB' = 4,
-  'TB' = 5,
-}

+ 0 - 133
client/src/utils/SizingTool.ts

@@ -1,133 +0,0 @@
-import { SIZE_STATUS } from '../pages/schema/Types';
-import { INDEX_TYPES_ENUM } from '@/consts';
-
-const commonValueCalculator = (
-  vector: number,
-  dimensions: number,
-  nlistArg: number,
-  fileSize: number
-) => {
-  const vectorCount = Math.min(fileSize / (dimensions * 4), vector);
-  const segmentCount = Math.round(vector / vectorCount);
-  const nlist = Math.min(nlistArg, vectorCount / 40);
-  return {
-    vectorCount,
-    segmentCount,
-    nlist,
-  };
-};
-
-const pqCalculator = (
-  vectorCount: number,
-  segmentCount: number,
-  dimensions: number,
-  m: number,
-  nlist: number
-) => {
-  const singleDiskSize =
-    nlist * dimensions * 4 + m * vectorCount + 256 * dimensions * 4;
-  const singleMemorySize = singleDiskSize + 256 * m * nlist * 4;
-  return {
-    pq_diskSize: singleDiskSize * segmentCount,
-    pq_memorySize: singleMemorySize * segmentCount,
-  };
-};
-
-export const computMilvusRecommonds = (
-  vector: number,
-  dimensions: number,
-  nlistArg: number,
-  m: number,
-  fileSize: number
-): { [key in string]: any } => {
-  const { vectorCount, segmentCount, nlist } = commonValueCalculator(
-    vector,
-    dimensions,
-    nlistArg,
-    fileSize
-  );
-
-  const { pq_diskSize, pq_memorySize } = pqCalculator(
-    vectorCount,
-    segmentCount,
-    dimensions,
-    m,
-    nlist
-  );
-
-  const size = vector * dimensions * 4;
-  const nlistSize = dimensions * 4 * nlist;
-  const byteSize = (dimensions / 8) * vector;
-
-  const rawFileSize = {
-    [INDEX_TYPES_ENUM.FLAT]: size,
-    [INDEX_TYPES_ENUM.IVF_FLAT]: size,
-    [INDEX_TYPES_ENUM.IVF_SQ8]: size,
-    [INDEX_TYPES_ENUM.IVF_SQ8_HYBRID]: size,
-    [INDEX_TYPES_ENUM.IVF_PQ]: size,
-  };
-
-  const memorySize = {
-    [INDEX_TYPES_ENUM.FLAT]: size,
-    [INDEX_TYPES_ENUM.IVF_FLAT]: size + nlistSize * segmentCount,
-    [INDEX_TYPES_ENUM.IVF_SQ8]: size * 0.25 + nlistSize * segmentCount,
-    [INDEX_TYPES_ENUM.IVF_SQ8_HYBRID]: size * 0.25 + nlistSize * segmentCount,
-    [INDEX_TYPES_ENUM.IVF_PQ]: pq_memorySize,
-  };
-
-  const diskSize = {
-    [INDEX_TYPES_ENUM.FLAT]: size,
-    [INDEX_TYPES_ENUM.IVF_FLAT]:
-      rawFileSize[INDEX_TYPES_ENUM.IVF_FLAT] +
-      memorySize[INDEX_TYPES_ENUM.IVF_FLAT],
-    [INDEX_TYPES_ENUM.IVF_SQ8]:
-      rawFileSize[INDEX_TYPES_ENUM.IVF_SQ8] +
-      memorySize[INDEX_TYPES_ENUM.IVF_SQ8],
-    [INDEX_TYPES_ENUM.IVF_SQ8_HYBRID]:
-      rawFileSize[INDEX_TYPES_ENUM.IVF_SQ8_HYBRID] +
-      memorySize[INDEX_TYPES_ENUM.IVF_SQ8_HYBRID],
-    [INDEX_TYPES_ENUM.IVF_PQ]:
-      rawFileSize[INDEX_TYPES_ENUM.IVF_PQ] + pq_diskSize,
-  };
-
-  const byteRawFileSize = {
-    [INDEX_TYPES_ENUM.BIN_FLAT]: byteSize,
-    [INDEX_TYPES_ENUM.BIN_IVF_FLAT]: byteSize,
-  };
-
-  const byteMemorySize = {
-    [INDEX_TYPES_ENUM.BIN_FLAT]: byteSize,
-    [INDEX_TYPES_ENUM.BIN_IVF_FLAT]: dimensions * nlist + byteSize,
-  };
-
-  const byteDiskSize = {
-    [INDEX_TYPES_ENUM.BIN_FLAT]: byteSize,
-    [INDEX_TYPES_ENUM.BIN_IVF_FLAT]:
-      byteRawFileSize[INDEX_TYPES_ENUM.BIN_IVF_FLAT] +
-      byteMemorySize[INDEX_TYPES_ENUM.BIN_IVF_FLAT],
-  };
-
-  return {
-    rawFileSize,
-    memorySize,
-    diskSize,
-    byteRawFileSize,
-    byteMemorySize,
-    byteDiskSize,
-  };
-};
-
-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 > 1024) {
-    size = size / 1024;
-    sizeStatus++;
-  }
-  status = SIZE_STATUS[sizeStatus] ?? 'KB';
-
-  size = Math.ceil(size);
-
-  return `${size} ${status}`;
-};

+ 0 - 1
client/src/utils/index.ts

@@ -4,6 +4,5 @@ export * from './Format';
 export * from './Insert';
 export * from './Metric';
 export * from './search';
-export * from './SizingTool';
 export * from './Sort';
 export * from './Validation';