As for factoring - I think I agree, not sure what the reasoning is
behind the current ordering. There are definitely some things that are
more verbose than necessary as well, agreed.
If a BSON v2 ever comes out I'd expect to see some of these gripes
addressed, but I wouldn't expect to see that switch anytime soon ;).
Thanks again for sharing your thoughts,
Mike
> To unsubscribe from this group, send email to bson+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>
On Mar 19, 7:53 am, Michael Dirolf <m...@10gen.com> wrote:
> Jay,
> I think that's a great post - the original design for BSON is courtesy
> of Dwight/Eliot so maybe they have some more thoughts, but I think
> some of the points you bring up are valid. One point about prepending
> document size is that it makes the format easy to traverse (including
> embedded docs, etc.). This is one of the core goals for the format
> (even if it can be a bit annoying to implement in some languages).
I have no objections to it. I think it would be nice to make it more
DB friendly. Does MongoDB internally reorder the elements to make them
more searchable?
> As for factoring - I think I agree, not sure what the reasoning is
> behind the current ordering. There are definitely some things that are
> more verbose than necessary as well, agreed.
Regarding the ordering, one side effect of the current way is that
\x00 is essentially a type tag that means "No more elements". If the
order was as I mentioned, then the parser loop would look instead for
an empty string as an element name. That means, of course, that the
order I proposed would disallow such element names. I'm not sure if
that's an intended feature of the current spec.
> If a BSON v2 ever comes out I'd expect to see some of these gripes
> addressed, but I wouldn't expect to see that switch anytime soon ;).
I don't expect it either! :P
Jay
No, the server doesn't do any reordering or anything like that. Adding
ordering or some other mechanism to make documents easier to search
would be an interesting thing to experiment with. I think one issue
there would be that it would take BSON a little bit further away from
the JSON spec (not necessarily a deal-breaker though IMO). It would
also create some trickiness because currently we enforce that command
"verbs" come first in documents (for the same reason - so we don't
have to search every key). Could certainly work around that as well
though.
>> As for factoring - I think I agree, not sure what the reasoning is
>> behind the current ordering. There are definitely some things that are
>> more verbose than necessary as well, agreed.
>
> Regarding the ordering, one side effect of the current way is that
> \x00 is essentially a type tag that means "No more elements". If the
> order was as I mentioned, then the parser loop would look instead for
> an empty string as an element name. That means, of course, that the
> order I proposed would disallow such element names. I'm not sure if
> that's an intended feature of the current spec.
I think allowing the empty key is important - but that last null byte
is already a bit superfluous since we have the document length prefix.
So reordering wouldn't necessarily break anything as far as I can
tell.
I just extracted the bson stuff to its own library, you can check it
out at:
http://github.com/kseg/Metsys.Bson/blob/master/Metsys.Bson/Serializer.cs
(pay particular attention to the NewDocument and EndDocument
implementations).
- No way to specify a date time's time zone. If the user converts a
date time with time zone to BSON it is easy enough to convert it UTC
time and get the ticks, but converting back again you have no
knowledge of what the time zone originally was and the user always
gets UTC
- No way to specify in BSON whether the root "document" is an object
or an array
~ James