Commit 214f2a76 by Ashutosh Mestry

ATLAS-3798: Import percentage display fix.

parent 935d0ab6
......@@ -89,11 +89,11 @@ public class BulkImporterImpl implements BulkImporter {
}
@VisibleForTesting
public static float updateImportProgress(Logger log, int currentIndex, int streamSize, float currentPercent, String additionalInfo) {
public static float updateImportProgress(Logger log, long currentIndex, long streamSize, float currentPercent, String additionalInfo) {
final double tolerance = 0.000001;
final int MAX_PERCENT = 100;
int maxSize = (currentIndex <= streamSize) ? streamSize : currentIndex;
long maxSize = (currentIndex <= streamSize) ? streamSize : currentIndex;
if (maxSize <= 0) {
return currentPercent;
}
......
......@@ -39,7 +39,7 @@ public class BulkImportPercentTest {
private List<Integer> percentHolder;
private Logger log;
public void setupPercentHolder(int max) {
public void setupPercentHolder(long max) {
percentHolder = new ArrayList<>();
}
......@@ -127,6 +127,15 @@ public class BulkImportPercentTest {
}
@Test
public void percentTest_Equal100M() throws Exception {
long streamSize = 100000000;
double[] expected = fillPercentHolderWith100();
runWithSize(streamSize);
assertEqualsForPercentHolder(expected);
}
@Test
public void percentTest_Equal4323() throws Exception {
int streamSize = 4323;
......@@ -153,7 +162,7 @@ public class BulkImportPercentTest {
assertTrue((f - MAX_PERCENT_FLOAT) <= 0.0001);
}
private void runWithSize(int streamSize) throws Exception {
private void runWithSize(long streamSize) throws Exception {
float currentPercent = 0;
setupPercentHolder(streamSize);
for (int currentIndex = 0; currentIndex < streamSize; currentIndex++) {
......@@ -161,7 +170,7 @@ public class BulkImportPercentTest {
}
}
private float invokeBulkImportProgress(int currentIndex, int streamSize, float currentPercent) throws Exception {
private float invokeBulkImportProgress(int currentIndex, long streamSize, float currentPercent) throws Exception {
return BulkImporterImpl.updateImportProgress(log, currentIndex, streamSize, currentPercent, "additional info");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment