Creating an RDD of a Class

If you have a custom class in your application, and you’re reading data from an external database, you might want the data to be presented as objects of your class. In the following example, by supplying User as a type parameter to the function while loading the MapR-DB table, you can create an RDD of the User class:

val userprofilesRDD = sc.loadFromMapRDB[User](“/tmp/user_profiles”)

You must define the User class by the Jackson semantics for Scala module. Jackson annotation is used for annotating the bean classes. For example:

case class User (@JsonProperty("_id") id:String, 
                 @JsonProperty("first_name") firstName:String,
                 @JsonProperty("last_name") lastName: String, 
                 @JsonProperty("dob") dob: ODate,
                 @JsonProperty("interests") interests: List[String])
Note: When a beanClass is specified, the SELECT clause is unnecessary and is ignored.