Skip to content

Instantly share code, notes, and snippets.

@danared
Created June 24, 2016 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danared/c8a7fb0f639803015bda4517df824093 to your computer and use it in GitHub Desktop.
Save danared/c8a7fb0f639803015bda4517df824093 to your computer and use it in GitHub Desktop.
def main(args: Array[String]): Unit = {
// Set up configurations
val sc = getSparkContext()
val sqlContext = SQLContext.getOrCreate(sc)
val readConfig = ReadConfig(Map("uri" -> "mongodb://127.0.0.1/movies.movie_ratings?readPreference=primaryPreferred"))
val writeConfig = WriteConfig(Map("uri" -> "mongodb://127.0.0.1/movies.user_recommendations"))
val userId = 0
// Load the movie rating data
val movieRatings = MongoSpark.load(sc, readConfig).toDF[UserMovieRating]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment