Arkay Arkay - 1 year ago 83
Java Question

Using a Java OutputFormat to emit Scala Tuples

I am trying to write a custom

for ArangoDB. I've used
as inspiration, swapping out the relevant drivers and calls etc. I wrote this in Java as I could not find a Scala example of an
. The class therefore is defined by:

public class ArangoOutputFormat<OUT extends Tuple> extends RichOutputFormat<OUT>

Now, my Flink program where I want to write to ArangoDB is written in Scala. The dataset
DataSet[Tuple2[Long, Long]]
. The call to write to ArangoDB looks like:

new ArangoOutputFormat[(Long, Long)]()

However when compiling I get the following error:

Error:(47, 11) type arguments [(Long, Long)] do not conform to class ArangoOutputFormat's type parameter bounds [OUT <:]
new ArangoOutputFormat(Long, Long)

I'm generally a little confused on the type system when using both Scala and Java classes, can anyone explain what is happening here?

Thanks in advance,

Answer Source

The ArangoOutputFormat is typed to Flink's Java Tuples ( whereas your Scala program uses Scala's Tuples. Flink's Java tuples are not compatible with Scala's tuples. You need to explicitly create Java Tuples for instance in a Mapper before the sink.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download