File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
reverse_engineering/helpers Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -131,13 +131,14 @@ const checkHaveJsonTypes = columns => {
131131 return _ . find ( columns , { type : 'json' } ) ;
132132} ;
133133
134- const getLimit = ( count , recordSamplingSettings ) => {
135- const per = recordSamplingSettings . relative . value ;
136- const size =
137- recordSamplingSettings . active === 'absolute'
138- ? recordSamplingSettings . absolute . value
139- : Math . round ( ( count / 100 ) * per ) ;
140- return Math . min ( size , 100000 ) ;
134+ const getSampleDocSize = ( count , recordSamplingSettings ) => {
135+ if ( recordSamplingSettings . active === 'absolute' ) {
136+ return Number ( recordSamplingSettings . absolute . value ) ;
137+ }
138+
139+ const limit = Math . ceil ( ( count * recordSamplingSettings . relative . value ) / 100 ) ;
140+
141+ return Math . min ( limit , recordSamplingSettings . maxValue ) ;
141142} ;
142143
143144const prepareTableConstraints = ( constraintsResult , attributesWithPositions , tableIndexes ) => {
@@ -355,6 +356,6 @@ module.exports = {
355356 prepareTableConstraints,
356357 prepareTableLevelData,
357358 prepareTableIndexes,
358- getLimit ,
359+ getSampleDocSize ,
359360 prepareTableInheritance,
360361} ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const {
2424 prepareTablePartition,
2525 checkHaveJsonTypes,
2626 prepareTableConstraints,
27- getLimit ,
27+ getSampleDocSize ,
2828 prepareTableLevelData,
2929 prepareTableIndexes,
3030 prepareTableInheritance,
@@ -372,7 +372,7 @@ module.exports = {
372372 const fullTableName = `${ schemaName } .${ tableName } ` ;
373373 const quantity =
374374 ( await db . queryTolerant ( queryConstants . GET_ROWS_COUNT ( fullTableName ) , [ ] , true ) ) ?. quantity || 0 ;
375- const limit = getLimit ( quantity , recordSamplingSettings ) ;
375+ const limit = getSampleDocSize ( quantity , recordSamplingSettings ) ;
376376
377377 const jsonColumns = attributes . filter ( ( { type } ) => _ . includes ( [ 'json' , 'jsonb' ] , type ) ) ;
378378
You can’t perform that action at this time.
0 commit comments