I'd recommend the array-of-pairs method because the parallel-arrays method
leaves you open to bugs where if the arrays aren't the same size and your
code doesn't carefully check for this, it could easily end up crashing due
to out-of-bounds accesses. This could be a security problem. Stick with
arrays of pairs and avoid the risk. The overhead isn't that big a deal.
2009/8/26 Alkis Evlogimenos ('Αλκης Ευλογημένος) <[email protected]>
> This incurs some serialization overhead and also in-memory/object overhead
> (in C++ it is not sure about Java). If that is not an issue (your strings
> are huge for example) what you suggest is a bit more self-documenting.
>
> 2009/8/26 DeWitt Clinton <[email protected]>
>
> I've also used the pattern:
>> message Map {
>> message Entry {
>> optional string name = 1;
>> optional string value = 2;
>> }
>> repeated Entry entries = 1;
>> }
>>
>> Alkis, do you see benefits or downsides between the two approaches?
>>
>> To the second question, perhaps pick a universal representation for dates,
>> such as RFC 3339 (http://tools.ietf.org/html/rfc3339) and use a string?
>>
>> -DeWitt
>>
>> 2009/8/26 rajesh <[email protected]>
>>
>>
>>> -Thanks
>>>
>>> On Aug 26, 2:46 pm, Alkis Evlogimenos ('Αλκης Ευλογημένος)
>>> <[email protected]> wrote:
>>> > Protocol buffers do not have a protobuf map equivalent. What is usually
>>> done
>>> > is to put 2 repeated fields in the proto, one for the keys and one for
>>> the
>>> > values of the map you are trying to represent.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, Aug 26, 2009 at 7:13 PM, rajesh <[email protected]> wrote:
>>> >
>>> > > Hi All,
>>> > > Iam kinda new to using protocol buffers, so this could be a
>>> > > dumb question. I am curious as to how or what should be the syntax of
>>> > > the protocol buffer message for Map implementations in java. I looked
>>> > > in the documentation, but dint find any such example message.
>>> > > Similarly what should be the field type in the protocol buffer
>>> message
>>> > > which corresponds to Date implemetations in java. I would appreciate
>>> > > if some one can guide me through this or point me to the
>>> documentation
>>> > > which will help me understand this aspect better. Thanks in advance.
>>> >
>>> > > -Raj
>>> >
>>> > --
>>> >
>>> > Alkis- Hide quoted text -
>>> >
>>> > - Show quoted text -
>>>
>>>
>>
>>
>>
>
>
> --
>
> Alkis
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---