cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

XML Unmarshalling using JAXB from JavaRDD

ShankarReddy
New Contributor II

I have a JavRDD with complex nested xml content that I want to unmarshall using JAXB and get the data in to java objects. Can anyone please help with how can I achieve?

Thanks

1 REPLY 1

ShankarReddy
New Contributor II

I hope this should work

JavaPairRDD<String, PortableDataStream> jrdd = javaSparkContext.binaryFiles("<path_to_file>");
Map<String, PortableDataStream> mp = jrdd.collectAsMap();
OutputStream os = new FileOutputStream(f);
mp.values().forEach(pd -> {
try {
os.write(pd.toArray());
} catch (IOException e) {
throw new RuntimeException(e);
}
});
os.flush();

And then supplying file to jaxb unmarshaller. Not sure if there is a better way.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group