Skip to content

Commit 3297a09

Browse files
authored
Merge pull request #7 from dannleed/fix/HCK-3553-standardization-of-sampling-restrictions
HCK-3553: standardize record sampling limitation
2 parents 0929582 + 0ec32dc commit 3297a09

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

reverse_engineering/api.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ const async = require('async');
77
const SchemaCreator = require('./SchemaCreator');
88
const versions = require('../package.json').contributes.target.versions;
99

10-
const MAX_DOCUMENTS = 30000;
11-
1210
let connectionParams = {};
13-
let saveConnectionInfo = {};
1411

1512
let _client = null;
1613

@@ -295,6 +292,16 @@ const shouldPackageBeAdded = (docPackage, includeEmptyCollection) => {
295292
return true;
296293
};
297294

295+
const getSampleDocSize = (count, recordSamplingSettings) => {
296+
if (recordSamplingSettings.active === 'absolute') {
297+
return Number(recordSamplingSettings.absolute.value);
298+
}
299+
300+
const limit = Math.ceil((count * recordSamplingSettings.relative.value) / 100);
301+
302+
return Math.min(limit, recordSamplingSettings.maxValue);
303+
};
304+
298305
const getIndexTypeData = (typeName, {
299306
indexName,
300307
recordSamplingSettings,
@@ -315,13 +322,9 @@ const getIndexTypeData = (typeName, {
315322
},
316323

317324
(response, searchData) => {
318-
const per = recordSamplingSettings.relative.value;
319-
const size = (recordSamplingSettings.active === 'absolute')
320-
? recordSamplingSettings.absolute.value
321-
: Math.round(response.count / 100 * per);
322-
const count = size > MAX_DOCUMENTS ? MAX_DOCUMENTS : size;
325+
const size = getSampleDocSize(response.count, recordSamplingSettings);
323326

324-
searchData(null, count);
327+
searchData(null, size);
325328
},
326329

327330
(size, getTypeData) => {

0 commit comments

Comments
 (0)