I'm building a small API around some spark code and I am finding myself creating traits like the following:
trait DataSource[T, F] {
def run(config: DataSourceConfig[T,F]): DataSourceResource[F]
}
Take type T to represent RDD[F]. Do you see the problem here? It's getting obnoxious here having to force users to define both types like this:
class MySource extends DataSource[RDD[String], String] {
}
I understand scala has some black magic when it comes to generics that may allow me to specify that F is really a type nested within T but I can't seem to figure out how it would be done.
Thing is- T could also be a DStream[String]. RDD and DStream do not inherit from the same trait or base class.
Any ideas? It would really clean up my API if I could just specify that F is nested within T and still be able to use F everywhere.