Skip to content

Commit 42f3e22

Browse files
committed
Minor changes
1 parent 04e57f0 commit 42f3e22

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataimport/ConsoleImportProgressListener.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,28 @@ public void onDataChunkStarted(ImportDataChunkStatus status) {
4242

4343
@Override
4444
public void onDataChunkCompleted(ImportDataChunkStatus status) {
45-
long elapsed = status.getEndTime().toEpochMilli() - status.getStartTime().toEpochMilli();
46-
totalRecords.addAndGet(status.getTotalRecords());
47-
totalSuccess.addAndGet(status.getSuccessCount());
48-
totalFailures.addAndGet(status.getFailureCount());
49-
if (status.getSuccessCount() > 0) {
50-
chunkLogs.put(
51-
status.getDataChunkId(),
52-
String.format(
53-
"✓ Chunk %d: %d records imported (%.1fs), %d records imported successfully, import of %d records failed",
54-
status.getDataChunkId(),
55-
status.getTotalRecords(),
56-
elapsed / 1000.0,
57-
status.getSuccessCount(),
58-
status.getFailureCount()));
59-
}
45+
long elapsedMillis = status.getEndTime().toEpochMilli() - status.getStartTime().toEpochMilli();
46+
double elapsedSeconds = elapsedMillis / 1000.0;
47+
48+
int chunkId = status.getDataChunkId();
49+
int total = status.getTotalRecords();
50+
int success = status.getSuccessCount();
51+
int failure = status.getFailureCount();
52+
53+
totalRecords.addAndGet(total);
54+
totalSuccess.addAndGet(success);
55+
totalFailures.addAndGet(failure);
56+
57+
String message =
58+
(failure == 0)
59+
? String.format(
60+
"✓ Chunk %d: %d records imported (%.1fs), %d records imported successfully",
61+
chunkId, total, elapsedSeconds, success)
62+
: String.format(
63+
"✓ Chunk %d: %d records imported (%.1fs), %d records imported successfully, import of %d records failed",
64+
chunkId, total, elapsedSeconds, success, failure);
65+
66+
chunkLogs.put(chunkId, message);
6067
}
6168

6269
@Override

0 commit comments

Comments
 (0)