Skip to content

Instantly share code, notes, and snippets.

@techisbeautiful
Created July 10, 2022 16:15
Show Gist options
  • Save techisbeautiful/6e2d6f9cf98933d1517a0c4a1885e34f to your computer and use it in GitHub Desktop.
Save techisbeautiful/6e2d6f9cf98933d1517a0c4a1885e34f to your computer and use it in GitHub Desktop.
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