Last active
May 26, 2021 14:04
-
-
Save girisandeep/4ce968fd961a3ed7c088bb669aa8bba9 to your computer and use it in GitHub Desktop.
This example first create sequencefile and then loads it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Save it | |
var rdd = sc.parallelize(Array(("key1", 1.0), ("key2", 2.0), ("key3", 3.0)), 2) | |
rdd.saveAsSequenceFile("pysequencefile1") | |
//Load it | |
import org.apache.hadoop.io.DoubleWritable | |
import org.apache.hadoop.io.Text | |
val myrdd = sc.sequenceFile( | |
"pysequencefile1", | |
classOf[Text], classOf[DoubleWritable]) | |
val result = myrdd.map{case (x, y) => (x.toString, y.get())} | |
result.collect() | |
//Array((key1,1.0), (key2,2.0), (key3,3.0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment