added check to verify that dump contains at least one product

This commit is contained in:
Miriam Baglioni 2020-07-07 18:21:35 +02:00
parent d86adb82a7
commit 8a1b42ff21
1 changed files with 11 additions and 7 deletions

View File

@ -98,13 +98,17 @@ public class SparkSplitForCommunity implements Serializable {
} }
private static void printResult(String c, Dataset<Result> result, String outputPath) { private static void printResult(String c, Dataset<Result> result, String outputPath) {
result Dataset<Result> community_products = result
.filter(r -> containsCommunity(r, c)) .filter(r -> containsCommunity(r, c));
.repartition(1)
.write() if(community_products.count() > 0){
.option("compression", "gzip") community_products.repartition(1)
.mode(SaveMode.Append) .write()
.json(outputPath + "/" + c); .option("compression", "gzip")
.mode(SaveMode.Overwrite)
.json(outputPath + "/" + c);
}
} }
private static boolean containsCommunity(Result r, String c) { private static boolean containsCommunity(Result r, String c) {