2014-10-29 10 views
5

बनाते समय नहीं मिला मैं केस क्लास ऑब्जेक्ट्स का आरडीडी बनाने की कोशिश कर रहा हूं। ।स्पार्क त्रुटि आरडीडी प्रकार आरडीडी

<console>:28: error: not found: type RDD 
     val people: RDD[Person] =sc.textFile("/user/root/people.txt").map(_.split(",")).map(p => Person(p(0), p(1).trim.toInt)) 

क्या गलत हुआ पर कोई विचार: उदाहरण के लिए,

// sqlContext from the previous example is used in this example. 
// createSchemaRDD is used to implicitly convert an RDD to a SchemaRDD. 
import sqlContext.createSchemaRDD 

val people: RDD[Person] = ... // An RDD of case class objects, from the previous example. 

// The RDD is implicitly converted to a SchemaRDD by createSchemaRDD, allowing it to be stored using  Parquet. 
people.saveAsParquetFile("people.parquet") 

मैं

case class Person(name: String, age: Int) 

    // Create an RDD of Person objects and register it as a table. 
    val people: RDD[Person] = sc.textFile("/user/root/people.txt").map(_.split(",")).map(p => Person(p(0), p(1).trim.toInt)) 
    people.registerAsTable("people") 

मैं निम्नलिखित त्रुटि मिलती देकर पिछले उदाहरण से भाग पूरा करने के लिए कोशिश कर रहा हूँ? अग्रिम धन्यवाद!

उत्तर

21

यहां मुद्दा स्पष्ट RDD[String] टाइप एनोटेशन है। ऐसा लगता है कि RDDspark-shell में डिफ़ॉल्ट रूप से आयात नहीं किया गया है, यही कारण है कि स्कैला शिकायत कर रही है कि इसे RDD प्रकार नहीं मिल रहा है। पहले import org.apache.spark.rdd.RDD चलाने का प्रयास करें।

+0

धन्यवाद एक टन, जोश। – user1189851

संबंधित मुद्दे