Skip to content

Commit

Permalink
fix double and float data generator
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid committed Nov 9, 2023
1 parent 940a7e1 commit e8afb56
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const findKeyValue = (obj: KeyValuePair[], key: string) =>

export const makeDynamicBool = () => Math.random() > 0.5;
export const makeRandomInt = () => Math.floor(Math.random() * 127);
export const makeFloat = () => Math.random();

export const genDataByType = ({ data_type, type_params }: FieldSchema) => {
switch (data_type) {
Expand All @@ -21,6 +22,10 @@ export const genDataByType = ({ data_type, type_params }: FieldSchema) => {
return Math.floor(Math.random() * 214748364);
case 'Int64':
return Math.floor(Math.random() * 214748364);
case 'Float':
return makeFloat();
case 'Double':
return makeFloat();
case 'FloatVector':
return Array.from({ length: (type_params as any)[0].value }).map(() =>
Math.random()
Expand Down

0 comments on commit e8afb56

Please sign in to comment.