forked from D-Net/dnet-hadoop
added check to verify that dump contains at least one product
This commit is contained in:
parent
d86adb82a7
commit
8a1b42ff21
|
@ -98,15 +98,19 @@ public class SparkSplitForCommunity implements Serializable {
|
|||
}
|
||||
|
||||
private static void printResult(String c, Dataset<Result> result, String outputPath) {
|
||||
result
|
||||
.filter(r -> containsCommunity(r, c))
|
||||
.repartition(1)
|
||||
Dataset<Result> community_products = result
|
||||
.filter(r -> containsCommunity(r, c));
|
||||
|
||||
if(community_products.count() > 0){
|
||||
community_products.repartition(1)
|
||||
.write()
|
||||
.option("compression", "gzip")
|
||||
.mode(SaveMode.Append)
|
||||
.mode(SaveMode.Overwrite)
|
||||
.json(outputPath + "/" + c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean containsCommunity(Result r, String c) {
|
||||
if (Optional.ofNullable(r.getContext()).isPresent()) {
|
||||
return r
|
||||
|
|
Loading…
Reference in New Issue