[DOCS-3241] Define sort order of BinData type in BSON Types reference Created: 23/Apr/14  Updated: 22/May/14  Resolved: 22/May/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.5

Type: Improvement Priority: Major - P3
Reporter: Matt Kangas Assignee: Tim Slavin
Resolution: Done Votes: 1
Labels: bson, indexing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-13697 Document indexing and/or ordering for... Closed
Participants:
Days since reply: 9 years, 38 weeks, 6 days ago

 Description   

In neither the BSON 1.0 spec nor the MongoDB BSON Types Reference do we document the index sort order of BinData.

We probably should include it in the MongoDB documentation since it is an important implementation detail. The actual sort order is:

  • First compare length
  • Then compare the one-byte subtype
  • Then compare the content byte-by byte

It's defined in bson/bson-inl.h and db/pipeline/value.cpp

The fact that size is compared first is surprising to some. See https://github.com/mongodb/mongo/pull/666, SERVER-3260, SERVER-9925 for related discussions.



 Comments   
Comment by Githook User [ 22/May/14 ]

Author:

{u'username': u'TimSlavinMongoDB', u'name': u'Tim Slavin (MongoDB)', u'email': u'tim.slavin@10gen.com'}

Message: DOCS-3241: added BinData sort order section

Signed-off-by: kay <kay.kim@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/8e02957470b0ec03463b5c976d6b88d4dccf680b

Generated at Thu Feb 08 07:45:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.