Created
July 10, 2022 16:15
-
-
Save techisbeautiful/6e2d6f9cf98933d1517a0c4a1885e34f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PCollection<String> resultCollection = productCollection.apply(ParDo | |
.of(new DoFn<String, String>() { | |
@ProcessElement | |
public void process(ProcessContext processContext) { | |
double average = processContext.sideInput(averagePrice); | |
String strings = processContext.element(); | |
assert strings!= null; | |
String[] splits = strings.split(","); | |
double price = Double.parseDouble(splits[3].trim()); | |
if (price >= average) { | |
processContext.output(String.join(",", splits[0], splits[1], splits[2], splits[3])); | |
} | |
} | |
}).withSideInputs(averagePrice)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment