I have a written a method in Scala that is using a method written in Java - processSale()
method takes util.List<Sale>
as a parameter.
But after groupByKey()
I'm getting an RDD[(String, Iterable[Sale])]
. I've tried to import scala.collection.JavaConverters._
and do SaleParser.processSale(a.asJava)
.
However it gives me an Iterable[Sale]
. How is it possible to convert it into a Java util.List
?
val parseSales: RDD[(String, Sale)] = rawSales
.map(sale => sale.Id -> sale)
.groupByKey()
.mapValues(a => SaleParser.processSale(???))
a.toSeq.asJava
Note that if this Iterable
is actually a Seq
, toSeq
just returns the same object.
See API doc for the complete list of conversions.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments