forked from D-Net/dnet-hadoop
[cleaning] avoid NPE
This commit is contained in:
parent
8b44afe5e5
commit
c18b8048c3
|
@ -151,11 +151,32 @@ public class CleanCfHbSparkJob {
|
||||||
private static <T extends Result> FlatMapFunction<T, IdCfHbMapping> flattenCfHbFn() {
|
private static <T extends Result> FlatMapFunction<T, IdCfHbMapping> flattenCfHbFn() {
|
||||||
return r -> Stream
|
return r -> Stream
|
||||||
.concat(
|
.concat(
|
||||||
r.getCollectedfrom().stream().map(KeyValue::getKey),
|
Optional
|
||||||
|
.ofNullable(r.getCollectedfrom())
|
||||||
|
.map(cf -> cf.stream().map(KeyValue::getKey))
|
||||||
|
.orElse(Stream.empty()),
|
||||||
Stream
|
Stream
|
||||||
.concat(
|
.concat(
|
||||||
r.getInstance().stream().map(Instance::getHostedby).map(KeyValue::getKey),
|
Optional
|
||||||
r.getInstance().stream().map(Instance::getCollectedfrom).map(KeyValue::getKey)))
|
.ofNullable(r.getInstance())
|
||||||
|
.map(
|
||||||
|
instances -> instances
|
||||||
|
.stream()
|
||||||
|
.map(i -> Optional.ofNullable(i.getHostedby()).map(KeyValue::getKey).orElse("")))
|
||||||
|
.orElse(Stream.empty())
|
||||||
|
.filter(StringUtils::isNotBlank),
|
||||||
|
Optional
|
||||||
|
.ofNullable(r.getInstance())
|
||||||
|
.map(
|
||||||
|
instances -> instances
|
||||||
|
.stream()
|
||||||
|
.map(
|
||||||
|
i -> Optional
|
||||||
|
.ofNullable(i.getCollectedfrom())
|
||||||
|
.map(KeyValue::getKey)
|
||||||
|
.orElse("")))
|
||||||
|
.orElse(Stream.empty())
|
||||||
|
.filter(StringUtils::isNotBlank)))
|
||||||
.distinct()
|
.distinct()
|
||||||
.filter(StringUtils::isNotBlank)
|
.filter(StringUtils::isNotBlank)
|
||||||
.map(cfHb -> asIdCfHbMapping(r.getId(), cfHb))
|
.map(cfHb -> asIdCfHbMapping(r.getId(), cfHb))
|
||||||
|
|
Loading…
Reference in New Issue