Reputation: 1167
I'm trying to adapt the code here from a Scala version to a PySpark version. Here's the code I'm using:
conf = SparkConf().setAppName("Parse Xml File")
sc = SparkContext(conf = conf)
sqlContext = HiveContext(sc)
sc._jsc.hadoopConfiguration().set('stream.recordreader.class', 'org.apache.hadoop.streaming.StreamXmlRecordReader')
sc._jsc.hadoopConfiguration().set('stream.recordreader.begin', '<page>')
sc._jsc.hadoopConfiguration().set('stream.recordreader.end', '</page>')
xml_sdf = sc.newAPIHadoopFile(xml_data_path,
'org.apache.hadoop.streaming.StreamInputFormat',
'org.apache.hadoop.io.Text',
'org.apache.hadoop.io.Text')
print("Found {0} records.".format(wiki_xml_sdf.count()))
sc.stop()
Error I'm getting is:
py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.newAPIHadoopFile.
: java.lang.ClassCastException: org.apache.hadoop.streaming.StreamInputFormat cannot be cast to org.apache.hadoop.mapreduce.InputFormat
Is there a different input format / settings that I can use to make it work?
Upvotes: 1
Views: 2842