Binary subtype question

160 views
Skip to first unread message

Claudio Bisegni

unread,
Mar 15, 2012, 1:07:02 PM3/15/12
to bs...@googlegroups.com
hi all,
i need to use the subtype value of bson for binary field. I have seen that is use \00 to \06 and \80 is for user defined. I need to describe the cogent of binary field with some custom structure that use base defined elsewhere. For every structure i'd like to use a free subtype code. Can i use code from \07 up to \80 for custom purpose, and remain bson compliant?

thanks in advanced

Scott Hernandez

unread,
Mar 15, 2012, 2:26:57 PM3/15/12
to bs...@googlegroups.com
If you are always the client and producer for all binary data in the
docs then using subtype 0 works well. If there will be other subtype 0
data in there then you will want to choose another unused number.
There is not a current registry for these reserved subtype numbers.

In short, yes; you can use any of the values from that range.

Claudio Bisegni

unread,
Mar 15, 2012, 2:53:03 PM3/15/12
to bs...@googlegroups.com
i think that for binary there is the necessity to leave a lot of space for custom purpose because i can put a lot of different structure into this field.
For example we are using BSON to store device data in our control system. A lot of device store, in binary field, an structured data (matrix, image and also strange structures) so i hope also in he future this field can be used for custom user struct.

Scott Hernandez

unread,
Mar 15, 2012, 3:19:01 PM3/15/12
to bs...@googlegroups.com
You can do that in the general binary subtype (0). It is up to you to
pack it in and out.

Claudio Bisegni

unread,
Mar 16, 2012, 4:18:25 AM3/16/12
to bs...@googlegroups.com
yes but using subtype, is my opinion is more "BSON" guidelines respect.
for example i can define a struct like that:
{int, int, double} and associate to it \10 as subtype(obviously i will have a MetadataServer that will have for every device definition of subtype associated with code) so in binary bson serialization i need only to put \10 as subtype.

I have a question, why there is a gap from last \06 subtype and \80 for user defined? can the subtype reach the \ff value, ore there are some issue on limit os value to use?

Il giorno giovedì 15 marzo 2012 20:19:01 UTC+1, Scott Hernandez ha scritto:
You can do that in the general binary subtype (0). It is up to you to
pack it in and out.

> i think that for binary there is the necessity to leave a lot of space for
> custom purpose because i can put a lot of different structure into this
> field.
> For example we are using BSON to store device data in our control system. A
> lot of device store, in binary field, an structured data (matrix, image and
> also strange structures) so i hope also in he future this field can be used
> for custom user struct.
>
> Il giorno giovedì 15 marzo 2012 18:07:02 UTC+1, Claudio Bisegni ha scritto:
>>
>> hi all,
>> i need to use the subtype value of bson for binary field. I have seen that
>> is use \00 to \06 and \80 is for user defined. I need to describe the cogent
>> of binary field with some custom structure that use base defined elsewhere.
>> For every structure i'd like to use a free subtype code. Can i use code from
>> \07 up to \80 for custom purpose, and remain bson compliant?
>>
>> thanks in advanced


Il giorno giovedì 15 marzo 2012 20:19:01 UTC+1, Scott Hernandez ha scritto:
You can do that in the general binary subtype (0). It is up to you to
pack it in and out.

Eliot Horowitz

unread,
Mar 17, 2012, 2:08:03 AM3/17/12
to bs...@googlegroups.com
The gap is just a reserved space so people can use custom subtypes
from 0x80 to 0xFF for their own, which then we can safely add more
below.

Claudio Bisegni

unread,
Mar 17, 2012, 3:38:16 AM3/17/12
to bs...@googlegroups.com
Ah ok i have mean that also other number below \80 and up \06 was do user definition.

Eliot Horowitz

unread,
Mar 17, 2012, 3:39:15 AM3/17/12
to bs...@googlegroups.com
The idea is that 0x6 to 0x80 is reserved.
So I wouldn't use that space for your own subtypes.

Claudio Bisegni

unread,
Mar 17, 2012, 4:29:19 AM3/17/12
to bs...@googlegroups.com
Ok Now i have mean, in spec this is not well specified, seem that only
\80 must be use for user scope.

Claudio

Il giorno 17/mar/2012, alle ore 08:39, Eliot Horowitz
<el...@10gen.com> ha scritto:

Reply all
Reply to author
Forward
0 new messages