12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- import { Option } from '@/components/customSelector/Types';
- import {
- METRIC_TYPES_VALUES,
- DataTypeStringEnum,
- DataTypeEnum,
- } from '@/consts';
- import { IForm } from '@/hooks';
- import { IndexType } from '@/pages/databases/collections/overview/Types';
- interface IInfo {
- [key: string]: any;
- }
- export const formatForm = (info: IInfo): IForm[] => {
- const form: IForm[] = Object.entries(info).map(item => {
- const [key, value] = item;
- return {
- key,
- value,
- needCheck: true,
- };
- });
- return form;
- };
- export const getMetricOptions = (
- indexType: IndexType,
- fieldType: DataTypeEnum
- ): Option[] => {
- const baseFloatOptions = [
- {
- value: METRIC_TYPES_VALUES.L2,
- label: 'L2',
- },
- {
- value: METRIC_TYPES_VALUES.IP,
- label: 'IP',
- },
- {
- value: METRIC_TYPES_VALUES.COSINE,
- label: 'COSINE',
- },
- ];
- const baseBinaryOptions = [
- {
- value: METRIC_TYPES_VALUES.HAMMING,
- label: 'HAMMING',
- },
- {
- value: METRIC_TYPES_VALUES.JACCARD,
- label: 'JACCARD',
- },
- {
- value: METRIC_TYPES_VALUES.TANIMOTO,
- label: 'TANIMOTO',
- },
- ];
- switch (fieldType) {
- case DataTypeEnum.FloatVector:
- case DataTypeEnum.Float16Vector:
- case DataTypeEnum.BFloat16Vector:
- return baseFloatOptions;
- case DataTypeEnum.SparseFloatVector:
- return [
- {
- value: METRIC_TYPES_VALUES.IP,
- label: 'IP',
- },
- ];
- case DataTypeEnum.BinaryVector:
- switch (indexType) {
- case 'BIN_FLAT':
- return [
- ...baseBinaryOptions,
- {
- value: METRIC_TYPES_VALUES.SUBSTRUCTURE,
- label: 'SUBSTRUCTURE',
- },
- {
- value: METRIC_TYPES_VALUES.SUPERSTRUCTURE,
- label: 'SUPERSTRUCTURE',
- },
- ];
- case 'BIN_IVF_FLAT':
- return baseBinaryOptions;
- default:
- return baseBinaryOptions;
- }
- default:
- return [];
- }
- };
|