parsing of optional parameter

This commit is contained in:
Claudio Atzori 2020-07-13 15:40:41 +02:00
parent 4c101a9d66
commit 7dd91edf43
1 changed files with 6 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.spark.SparkConf; import org.apache.spark.SparkConf;
@ -76,14 +77,11 @@ public class SparkCreateMergeRels extends AbstractSparkAction {
final String workingPath = parser.get("workingPath"); final String workingPath = parser.get("workingPath");
final String isLookUpUrl = parser.get("isLookUpUrl"); final String isLookUpUrl = parser.get("isLookUpUrl");
final String actionSetId = parser.get("actionSetId"); final String actionSetId = parser.get("actionSetId");
int cut = 0; int cut = Optional
try { .ofNullable(parser.get("cutConnectedComponent"))
cut = Integer.parseInt(parser.get("cutConnectedComponent")); .map(Integer::valueOf)
.orElse(0);
} catch (Throwable e) { log.info("connected component cut: '{}'", cut);
log.error("unable to parse " + parser.get(" cut-off threshold"));
}
log.info("graphBasePath: '{}'", graphBasePath); log.info("graphBasePath: '{}'", graphBasePath);
log.info("isLookUpUrl: '{}'", isLookUpUrl); log.info("isLookUpUrl: '{}'", isLookUpUrl);
log.info("actionSetId: '{}'", actionSetId); log.info("actionSetId: '{}'", actionSetId);