I have a Java interface Writer defined as following:
public interface Writer<K, V> {
Iterator<Product2<K, V>> iterator ();
}
And i am trying to implement this interface in a Scala class ExternalWriter which is as following:
private class ExternalWriter[K, V, C]
extends Logging
with Writer[K, V] {
override def iterator(): Iterator[Product2[K, C]] = {
partitionedIterator.flatMap(pair => pair._2)
}
}
But when I try to compile this code, I get an error:
Error: Overriding method iterator in trait SortShuffleFileWriter of type ()Iterator[Product2[K,V]]; method iterator has incompatible type override def iterator(): Iterator[Product2[K, C]] = {
How do I fix this?
java.util.Iterator
interface is separate from thescala.collection.Iterator
trait (in addition to the problem @Codebender mentioned). Did you account for that? – Silly Freak