Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
imedina committed Jul 28, 2017
2 parents fce8432 + aa506bd commit 257851e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion commons-datastore/commons-datastore-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.commons</groupId>
<artifactId>commons-datastore</artifactId>
<version>3.4.2</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion commons-datastore/commons-datastore-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.commons</groupId>
<artifactId>commons-datastore</artifactId>
<version>3.4.2</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion commons-datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.commons</groupId>
<artifactId>commons</artifactId>
<version>3.4.2</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion commons-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.opencb.commons</groupId>
<artifactId>commons</artifactId>
<version>3.4.2</version>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
14 changes: 8 additions & 6 deletions commons-lib/src/main/java/org/opencb/commons/ProgressLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.text.DecimalFormat;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

/**
Expand All @@ -41,7 +42,7 @@ public class ProgressLogger {
private final int numLinesLog;
private long totalCount;
private boolean isApproximated; // Total count is an approximated value
private Future<Long> futureTotalCount;
private final AtomicReference<Future<Long>> futureTotalCount = new AtomicReference<>();
private final AtomicLong count;

private double batchSize;
Expand Down Expand Up @@ -86,7 +87,7 @@ private ProgressLogger(String message, long totalCount, Future<Long> futureTotal
}
this.numLinesLog = numLinesLog;
this.totalCount = totalCount;
this.futureTotalCount = futureTotalCount;
this.futureTotalCount.set(futureTotalCount);
this.count = new AtomicLong();
if (totalCount == 0) {
batchSize = DEFAULT_BATCH_SIZE;
Expand Down Expand Up @@ -161,16 +162,17 @@ protected void print(String m) {
}

private void updateFutureTotalCount() {
if (futureTotalCount != null) {
if (futureTotalCount.isDone()) {
Future<Long> future = futureTotalCount.get();
if (future != null) {
if (future.isDone()) {
try {
totalCount = futureTotalCount.get();
totalCount = future.get();
updateBatchSize();
isApproximated = false;
} catch (InterruptedException | ExecutionException ignore) {
logger.warn("There was a problem calculating the total number of elements");
} finally {
futureTotalCount = null;
futureTotalCount.set(null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ public static void printCommandUsage(JCommander commander, PrintStream printStre
if (parameterDescription.getParameter() != null && !parameterDescription.getParameter().hidden()) {
String type = getType(parameterDescription);
String defaultValue = "";
if (parameterDescription.getDefault() != null && !parameterDescription.isDynamicParameter()) {
defaultValue = ("[" + parameterDescription.getDefault() + "]");
if (parameterDescription.getDefault() != null) {
if (parameterDescription.isDynamicParameter()) {
Object def = parameterDescription.getDefault();
if (def instanceof Map && !((Map) def).isEmpty()) {
defaultValue = ("[" + def + "]");
}
// defaultValue = ("[" + parameterDescription.getDefault() + "]");
} else {
defaultValue = ("[" + parameterDescription.getDefault() + "]");
}
}
String usage = String.format("%5s %-" + paramNameMaxSize + "s %-" + typeMaxSize + "s %s %s\n",
(parameterDescription.getParameterized().getParameter() != null
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.opencb.commons</groupId>
<artifactId>commons</artifactId>
<version>3.4.2</version>
<version>3.5.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>OpenCB commons project</name>
Expand All @@ -19,7 +19,7 @@
</modules>

<properties>
<java.commons.version>3.4.2</java.commons.version>
<java.commons.version>3.5.0-SNAPSHOT</java.commons.version>
<compileSource>1.8</compileSource>
<jackson.version>2.8.4</jackson.version>
<apache.commons.version>3.5</apache.commons.version>
Expand Down

0 comments on commit 257851e

Please sign in to comment.