Ich versuche eine der Strahl Google Dataflow-Pipeline-Beispiele, aber ich stoße auf eine Ausnahme in Bezug auf MapElements und Methoden SingleFunction/SerializableFunction Anrufe. Das Code-Snippet ist die folgende:Apache Beam Dataflow SDK Fehler mit Beispiel
static class ParseTableRowJson extends SimpleFunction<String, TableRow> {
@Override
public TableRow apply(String input) {
try {
return Transport.getJsonFactory().fromString(input, TableRow.class);
} catch (IOException e) {
throw new RuntimeException("Failed parsing table row json", e);
}
}
}
......
p.apply(TextIO.read().from(options.getInput()))
.apply(MapElements.via(new ParseTableRowJson()))
.apply(new ComputeTopSessions(samplingThreshold))
.apply("Write",
TextIO.write().withoutSharding().to(options.getOutput()));
Die Ausnahme, dass seine ein mehrdeutiger Aufruf der Methoden:
Ambiguous method call. Both
via (SimpleFunction<String, TableRow>) in MapElements and
via (SerializableFunction) in MapElements match
Hat jemand anderes in die gleiche Ausnahme gestoßen und bekam einen Weg darum herum?
Das vollständige Beispiel ist in GitHub (https://github.com/apache/beam/blob/master/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java).
Danke,
Fernando
Hallo Ben, danke für die Antwort, ich habe am Ende die MapElements zu einem DoFn umgewandelt, wie du gesagt hast und es hat gut funktioniert. –