Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Union or any

1 view
Skip to first unread message

Bogdan Jeram

unread,
Mar 12, 2009, 7:52:16 AM3/12/09
to
Hi,

I have to solve a problem to solve an arbitrary data (actually there are
several types) from a client to the server, and I am in dilemma should I
use IDL union or IDL any for solving the problem.

What is better to use (any or union) in terms of network traffic and CPU
usage (marshaling/marshaling) ?

Thanks
Bogdan

Douglas C. Schmidt

unread,
Mar 12, 2009, 8:19:42 AM3/12/09
to
Hi Bogdan,

unions will generally be better since they send less metadata and are
usually faster to marshal/demarshal.

Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.sc...@vanderbilt.edu

Jon Biggar

unread,
Mar 12, 2009, 12:09:54 PM3/12/09
to

If the number of types you need to support isn't too large (a half dozen
or so), and you don't project that future evolution of your interface
will require adding more types, then go with a union, since it's more
efficient on the wire.

You can also go with a hybrid approach, where you have a union for
simple times (number, strings) and have an "other" choice in the union
that uses an any. Then for simple datatypes you don't have the wire
overhead of the any, but you still have the option in the future to use
it without having to change your IDL.

--
Jon Biggar
j...@biggar.org
j...@floorboard.com

0 new messages