Subject: [forces] on the utility of unions

From: Jamal Hadi Salim <[email-masked]>
Date: Thu, 30 May 2013 11:15:37 -0400

Without going into a lot of details - this came up as i tried to implement
union support in our code and a private discussion with Evangelos.
I will try to sumarize but it may be a long email ;->

Unions look great from a model perspective; they also save memory use on
a machine.
One of the things Evangelos and I initially thought was a great idea was
something like:

union myaddress {
         1:ipv4address ip
         2:ipv6address ip6
}

This looks good. I can now manipulate the component myunion from the CE.
Setting path to be /myaddress/ip or /myaddress/ip6 is reasonable. And you
can
play small tricks to let someone use /myaddress as a path (but thats a
separate
topic of discussion). We get the ideal use case of unions.

The challenge starts showing up when you have hierachies.
Example:

mystruct  blah {
         1: myaddress fooaddress
         2: uint32 bar
}

There is no clean way of getting the path /blah from the FE
(compare to when blah had no unions). This is because
it is ambigous within /blah/myaddress whether i am referring to
/blah/myaddress/ip or ip6 when i do the get.
I could construct a query with multiple paths to retrieve /blah
but i am questioning the usefulness of wasting wire-bits and more
cpu for encoding/decoding in order to save host-bits (memory)
just for the sake of being able to model something like this as
a union.
Things get worse if i have a table whose rows are struct blah
and say i needed to dump a few table entries.
Note: I left out the direction of CE->FE setting because less acrobatics
involved (but still inefficient).

Thoughts?

My suggestion is to define things that need to be modelled this
way as structs with /optional constructs.

cheers,
jamal

---

From: Joel <[email-masked]>
Date: Thu, 30 May 2013 11:33:46 -0400

Thinking about it, you are probably right.  Union does not actually 
usefully solve the problem it aimed at.
There is a minor issue that if you use a discriminator plus 2 or more 
optional fields, then the definition dos not capture the fact that one 
of the fields must be present.  I think that this is a price we can 
afford to pay.

Yours,
Joe

On 5/30/2013 11:15 AM, Jamal Hadi Salim wrote:
> Setting path to be /myaddress/ip or /myaddress/ip6 is reasonable. And
> you can
> _______________________________________________
> forces mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/forces
>

---

From: Jamal Hadi Salim <[email-masked]>
Date: Thu, 30 May 2013 17:41:16 -0400

Joel,

Makes sense.

cheers,
jamal

On Thu, May 30, 2013 at 11:33 AM, Joel <[email-masked]> wrote:

> optional fields, then the definition dos not capture the fact that one of
> the fields must be present.  I think that this is a price we can afford to
> pay.
>
> Yours,
> Joe
>
>
>> ______________________________**_________________
>> forces mailing list
>> [email-masked]
>> https://www.ietf.org/mailman/**listinfo/forces<https://www.ietf.org/mailman/listinfo/forces>
>>
>>

---

From: "Adrian Farrel" <[email-masked]>
Date: Fri, 31 May 2013 03:22:13 +0100

Just for the hell of it...
 
Currently very sleep deprived and catching up with the ForCES list I came across
this thread with subject line "on the utility of unicorns"
 
Thanks for that :-)
 
Adrian
 
From: [email-masked] [mailto:[email-masked]] On Behalf Of
Jamal Hadi Salim
Sent: 30 May 2013 22:41
To: Joel
Cc: [email-masked]
Subject: Re: [forces] on the utility of unions
 
Joel,
 
Makes sense.
 
cheers,
jamal
 
On Thu, May 30, 2013 at 11:33 AM, Joel <[email-masked]> wrote:
Thinking about it, you are probably right.  Union does not actually usefully
solve the problem it aimed at.
There is a minor issue that if you use a discriminator plus 2 or more optional
fields, then the definition dos not capture the fact that one of the fields must
be present.  I think that this is a price we can afford to pay.

Yours,
Joe

union myaddress {
          1:ipv4address ip
          2:ipv6address ip6
}

mystruct  blah {
          1: myaddress fooaddress
          2: uint32 bar
}

Thoughts?

cheers,
jamal