Chris Black wrote:
Hello, I'm a new JiBX user and have been through the full tutorial and
have some simple bindings up and running. I am evaluating JiBX (along
with StAX) as a replacement for JDOM for serializing fairly large sets
(thousands of elements) of data that have lots of nested collections
(lists and maps, I know the issues and approaches with maps in JiBX
already). Given this background, I have two questions:
1) When using JDOM we found good speedups by adding the count of
elements in our xml so that when deserializing we could create the
collection with the proper capacity once, rather than having it
automatically grow in the background. This gives XML like:
<DataList count="5234">
<DataElement attribFoo="blah" attribBar="gibble"/>
<DataElement attribFoo="fred" attribBar="barney"/>
...
<DataElement attribFoo="mip" attribBar="pirney"/>
</DataList>
How would I go about using the value of the count attribute to set the
initial capacity of a collection using JiBX? I see from the collection
element docs that there is a size-element used to query the size, and
also a load-method, although from the docs I am not totally clear on
what the load-method does, it does not see to do what I wish.
The count attribute usage would probably make a nice enhancement, but
JiBX's collection handling currently doesn't support it. I don't think
it would make a significant difference in performance anyway, except
perhaps for collections of primitive values. The size-method and
load-method are only used as an alternative way of accessing collection
data (so JiBX calls the size-method to find out how many items are
present, then calls the load-method to get each one in turn).
2) Is there a recommended best-practices way to handle hierarchies of
collections in JiBX? I've found a few mentions in searching the
mailing lists but haven't found anything definitive or really to my
liking. The issues here are two-fold: how to handle mappings in a
modular fashion (my plan is to use the include element) and also how
to handle the binding factory. For the factory, should I just specify
the class at the top of the hierarchy? Would this allow me to create
subsets (export just some sublists) with something else as the root
element?
If I understand you correctly the best way to handle this is probably to
use abstract mappings with type-names for the nested collections. This
allows you to define multiple representations for a class or interface
(such as java.util.ArrayList or java.util.List), invoking them as
appropriate. Then you'd just need to have your top-level classes
reference the appropriate representation to use in a particular context.
- Dennis
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users