IJ E HW6 Movie CounterDataset Open 1//HW7 2 3 import org.apache.spark.sql._ 4 import org.apache.log4j._ 5 import org.apa
Posted: Fri Jul 01, 2022 5:39 am
Open set. E HW6 Movie CounterDataset -/Downloads 8 9 // Create case class with schema of u.data 10 // userID: Int, movieID: Int, rating: Int, timestamp: Long 11 12 13 // Create schema when reading u.data 14 15 16 17 18 19 20 // Load up the data into spark dataset 21 // Use tab as separator "\t", val user Ratings Schema= new StructType() .add("userID", IntegerType, nullable = true) .add("movieID", IntegerType, nullable = true) .add("rating", IntegerType, nullable = true) .add("timestamp", LongType, nullable = true) Save 22 // Load schema from user Ratingsschema and 23 // force case class to read it as dataset 24 25 26 // Select only ratings column 27 // (The file format is user ID, movieID, rating, timestamp) 28 31 // Sort the resulting dataset by count column 32 33 // Print results from the dataset 34 C Tab Width: 8 ||| 29 // Count up how many times each value (rating) occurs using grougBy and count 30 D Ln 1, Col 1 INS