cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Pieber <andreas.pie...@schmutterer-partner.at>
Subject Re: [C3] StAX research reveiled!
Date Sat, 27 Dec 2008 13:13:37 GMT

On Saturday 27 December 2008 10:36:07 Sylvain Wallez wrote:
> Michael Seydl wrote:
> > Hi all!
> >
> > One more mail for the student group! Behind this lurid topic hides our
> > evaluation of the latest XML processing technologies regarding their
> > usability in Cocoon3 (especially if there are suited to be used in a
> > streaming pipeline).
> > As it's commonly know we decided to use StAX as our weapon of choice
> > to do the XML, but this paper should explain the whys and hows and
> > especially the way we took to come to our decision, which resulted in
> > using the very same API.
> > Eleven pages should be a to big read and it contains all necessary
> > links to all the APIs we evaluated and also line wise our two cents
> > about the API we observed. Concludingly we also tried to show the
> > difference between the currently used SAX and the of us proposed StAX
> > API.
> >
> > I hope this work sheds some light on our decision making and taking
> > and that someone dares to read it.
> >
> > That's from me, I wish you all a pleasant and very merry Christmas!
> >
> > Regards,
> > Michael Seydl
>
> Good work and interesting read, but don't agree with some of its
> statements!
>
> The big if/else or switch statements mentioned as a drawback of the
> cursor API (XMLStreamReader) in 1.2.4 also apply to the event API, since
> it provides abstract events whose type needs also to be inspected to
> decide what to do.

Of course, you're right!

>
> The drawbacks of the stream API compared to the event API are, as you
> mention, that some methods of XMLStreamReader will throw an exception
> depending on the current event's type and that the event is not
> represented as a data structure that can be passed directly to the next
> element in the pipeline or stored in an event buffer.
>
> The first point (exceptions) should not happen, unless the code is buggy
> and tries to get information that doesn't belong to the context. I have
> used many times the cursor API and haven't found any usability problems
> with it.

Also here you're right, but IMHO it is not necessary to add another source for 
bugs if not required...

>
> The second point (lack of data structure) can be easily solved by using
> an XMLEventAllocator [1] that creates an XMLEvent from the current state
> of an XMLStreamReader.

Mhm but if we use an XMLEventAllocator, y not directly use the StAXEvent api?

>
> The event API has the major drawback of always creating a new object for
> every event (since as the javadoc says "events may be cached and
> referenced after the parse has completed"). This can lead to a big
> strain on the memory system and garbage collection on a busy application.

Thats right, but having in mind to create a pull pipe, where the serializer 
pulls each event from the producer through each transformer and writing it to an 
output stream we don't have any other possibility than creating an object for 
each event.

Think about it a little more in detail. To be able to pull each event you have 
to have the possibility to call a method looking like:

Object next();

on the parent of the pipelineComponent. Doing it in a StAX cursor way means to 
increase the complexity from one method to 10 or more which have to be available 
through the parent...

>
> So the cursor API is the most efficient IMO when it comes to consuming
> data, since it doesn't require creating useless event objects.
>
> Now in a pipeline context, we will want to transmit events untouched
> from one component to the next one, using some partial buffering as
> mentioned in earlier discussions. A FIFO of XMLEvent object seems to be
> the natural solution for this, but would require the use of events at
> the pipeline API level, with their associated costs mentioned above.

I'm not sure if I get the point here, but we do not like to "transmit" events. 
They are pulled. Therefore in most cases we simply do not need a buffer, since 
events could be directly returned.

>
> So what should be used for pipelines ? My impression is that we should
> stick to the most efficient API and build the simple tools needed to
> buffer events from a StreamReader, taking inspiration from the
> XMLBytestreamCompiler we already have.

Maybe some events could be avoided using the cursor API, but IMO the performance 
we could get is not worth the simplicity we sacrifice...

>
> Sylvain

Andreas

>
> [1]
> https://stax-utils.dev.java.net/nonav/javadoc/api/javax/xml/stream/util/XML
>EventAllocator.html
-- 
SCHMUTTERER+PARTNER Information Technology GmbH

Hiessbergergasse 1
A-3002 Purkersdorf

T   +43 (0) 69911127344
F   +43 (2231) 61899-99
mail to: andreas.pieber@schmutterer-partner.at

Mime
View raw message