I want to do a mapPartitions on my spark rdd,
val newRd = myRdd.mapPartitions(
partition => {
val connection = new DbConnection /*crea
rdd.foreachPartitionAsync(iterator->{
// this object will be cached inside each executor JVM. For the first time, the //connection will be created and hence forward, it will be reused.
// Very useful for streaming apps
DBConn conn=DBConn.getConnection()
while(iterator.hasNext()) {
conn.read();
}
});
public class DBConn{
private static dbObj=null;
//Create a singleton method that returns only one instance of this object
}
}