Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add with_raw_data for Scann index #549

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions client/src/consts/Milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export type indexConfigType = {
// index
export const FLOAT_INDEX_CONFIG: indexConfigType = {
SCANN: {
create: ['nlist'],
create: ['nlist', 'with_raw_data'],
search: ['nprobe'],
},
IVF_FLAT: {
Expand All @@ -156,10 +156,6 @@ export const FLOAT_INDEX_CONFIG: indexConfigType = {
create: ['M', 'efConstruction'],
search: ['ef'],
},
ANNOY: {
create: ['n_trees'],
search: ['search_k'],
},
AUTOINDEX: {
create: [],
search: ['level'],
Expand All @@ -173,7 +169,7 @@ export const FLOAT_INDEX_CONFIG: indexConfigType = {
export const BINARY_INDEX_CONFIG: indexConfigType = {
// },
BIN_FLAT: {
create: ['nlist'],
create: [],
search: [],
},
BIN_IVF_FLAT: {
Expand Down
1 change: 0 additions & 1 deletion client/src/hooks/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const useFormValidation = (form: IForm[]): IValidationInfo => {
const [disabled, setDisabled] = useState<boolean>(!isOverallValid);

const checkIsValid = (param: ICheckValidParam): IValidationItem => {
console.log(param)
const { value, key, rules } = param;

let validDetail = {
Expand Down
26 changes: 3 additions & 23 deletions client/src/pages/databases/collections/overview/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ const CreateIndex = (props: {
m: '4',
efConstruction: '',
nlist: '',
nbits: '',
nbits: '8',
n_trees: '',
outDegree: '',
candidatePoolSize: '',
searchLength: '',
knng: '',
drop_ratio_build: '0.5',
with_raw_data: 'true',
});

// control whether show code mode
Expand Down Expand Up @@ -213,31 +215,9 @@ const CreateIndex = (props: {
validation,
checkIsValid,
disabled,
setDisabled,
resetValidation,
checkFormValid,
} = useFormValidation(checkedForm);
// reset index params
useEffect(() => {
// no need
// setDisabled(true);
setIndexSetting(v => ({
...v,
index_name: v.index_name,
metric_type: defaultMetricType,
M: '',
m: '4',
efConstruction: '',
nlist: '',
nbits: '8', // 8 by default
n_trees: '',
out_degree: '',
candidate_pool_size: '',
search_length: '',
knng: '',
drop_ratio_build: '0.5',
}));
}, [setDisabled, defaultMetricType]);

const updateStepTwoForm = (type: string, value: string) => {
setIndexSetting(v => ({ ...v, [type]: value }));
Expand Down
137 changes: 89 additions & 48 deletions client/src/pages/databases/collections/overview/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ const CreateForm = (
const { t: warningTrans } = useTranslation('warning');

const paramsConfig: ITextfieldConfig[] = useMemo(() => {
const generateNumberConfig = (
label: string,
key: string,
min: number,
max: number
) => {
const generateConfig = (props: {
label: string;
key: string;
min?: number;
max?: number;
type?: string;
}) => {
const { label, key, min, max, type = 'number' } = props;
const config: ITextfieldConfig = {
label,
key,
Expand All @@ -63,58 +65,98 @@ const CreateForm = (
},
variant: 'filled',
fullWidth: true,
type: 'number',
type: type,
value: formValue[key],
validations: [
{
rule: 'require',
errorText: warningTrans('required', { name: label }),
},
{
rule: 'range',
errorText: warningTrans('range', { min, max }),
extraParam: {
min,
max,
type: 'number',
},
},
],
};

if (type === 'number') {
config.validations!.push({
rule: 'range',
errorText: warningTrans('range', { min, max }),
extraParam: {
min,
max,
type: 'number',
},
});
}

if (type === 'bool') {
config.validations!.push({
rule: 'bool',
errorText: warningTrans('bool', { name: label }),
});
}
return config;
};

const paramsMap = {
nlist: generateNumberConfig('nlist', 'nlist', 1, 65536),
nbits: generateNumberConfig('nbits', 'nbits', 1, 16),
M: generateNumberConfig('M', 'M', 1, 2048),
efConstruction: generateNumberConfig(
'Ef Construction',
'efConstruction',
1,
2147483647
),
n_trees: generateNumberConfig('nTrees', 'n_trees', 1, 1024),
out_degree: generateNumberConfig('out_degree', 'out_degree', 5, 300),
candidate_pool_size: generateNumberConfig(
'candidate_pool_size',
'candidate_pool_size',
50,
1000
),
search_length: generateNumberConfig(
'search_length',
'search_length',
10,
300
),
knng: generateNumberConfig('knng', 'knng', 5, 300),
drop_ratio_build: generateNumberConfig(
'drop_ratio_build',
'drop_ratio_build',
0,
1
),
nlist: generateConfig({
label: 'nlist',
key: 'nlist',
min: 1,
max: 65536,
}),
nbits: generateConfig({
label: 'nbits',
key: 'nbits',
min: 1,
max: 16,
}),
M: generateConfig({ label: 'M', key: 'M', min: 2, max: 2048 }),
efConstruction: generateConfig({
label: 'efConstruction',
key: 'efConstruction',
min: 1,
max: 2147483647,
}),
n_trees: generateConfig({
label: 'n_trees',
key: 'n_trees',
min: 1,
max: 1024,
}),
out_degree: generateConfig({
label: 'out_degree',
key: 'out_degree',
min: 5,
max: 300,
}),
candidate_pool_size: generateConfig({
label: 'candidate_pool_size',
key: 'candidate_pool_size',
min: 50,
max: 1000,
}),
search_length: generateConfig({
label: 'search_length',
key: 'search_length',
min: 10,
max: 300,
}),
knng: generateConfig({
label: 'knng',
key: 'knng',
min: 5,
max: 300,
}),
drop_ratio_build: generateConfig({
label: 'drop_ratio_build',
key: 'drop_ratio_build',
min: 0,
max: 1,
}),
with_raw_data: generateConfig({
label: 'with_raw_data',
key: 'with_raw_data',
type: 'bool',
}),
};

const result: ITextfieldConfig[] = [];
Expand All @@ -135,8 +177,7 @@ const CreateForm = (
variant: 'filled',
fullWidth: true,
validations: [],
defaultValue: '',
value: formValue.index_name,
defaultValue: formValue.index_name,
};

return (
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/databases/collections/overview/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type IndexType =
| INDEX_TYPES_ENUM.IVF_PQ
// | 'RNSG'
| INDEX_TYPES_ENUM.HNSW
| INDEX_TYPES_ENUM.ANNOY
| INDEX_TYPES_ENUM.BIN_IVF_FLAT
| INDEX_TYPES_ENUM.BIN_FLAT
| INDEX_TYPES_ENUM.MARISA_TRIE
Expand Down
7 changes: 4 additions & 3 deletions client/src/utils/Validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@ export const checkDuplicate = (param: {
};

export const checkBool = (value: string): boolean => {
return value === 'true' || value === 'false';
}
const v = String(value).toLowerCase();
return v === 'true' || v === 'false';
};

export const checkNumber = (value: string): boolean => {
return !isNaN(Number(value));
}
};

export const getCheckResult = (param: ICheckMapParam): boolean => {
const { value, extraParam = {}, rule } = param;
Expand Down
Loading