BeanIO supporting streaming

214 views
Skip to first unread message

aj

unread,
Sep 17, 2014, 9:31:32 AM9/17/14
to bea...@googlegroups.com
Hi,

I have a question related to the way beanio converts flat files etc to pojo's. Currently, the way beanio works is that you provide it the layout file and the actual file path and it maps the contents of the file to the required java beans. Is it possible to have beanio take in a layout and a string( or for that matter any object ) i.e. basically a single record, such that beanio only maps that specific string/object according to the specified layout?

For example:

//Initialize layout
 StreamFactory factory = StreamFactory.newInstance();
 factory.loadResource("mapping/beanio-test.xml");

//Specify single record
 String record = "Detail,\"Joe\",Smith,Developer,75000,10012009";
 BeanReader reader = factory.createReader("employeeFile", null, null);

//Map record to java bean
 emp = (Employee)reader.read(record);

The use case for this could be in real time streaming applications like Storm/Spark streaming where the bean creation could be parallelized across multiple instances without doing all the bean creation in a single process itself. Semantics of order etc will need to be preserved by the part of the application consuming this data.

I have gotten this to work locally and I was wondering what the thoughts of the community were on this.

Best,

AJ

Kevin

unread,
Sep 20, 2014, 3:28:32 PM9/20/14
to bea...@googlegroups.com
Hi AJ,

You'll probably want to use an Unmarshaller instead of a BeanReader.  See http://beanio.org/2.1/docs/api/org/beanio/Unmarshaller.html.

Thanks,
Kevin

arjun rao

unread,
Sep 23, 2014, 12:13:55 PM9/23/14
to bea...@googlegroups.com
Works like a charm! 

Thanks,

-AJ

--
You received this message because you are subscribed to a topic in the Google Groups "beanio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beanio/NA5MrQYQwI4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beanio+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages