Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-3241

Define sort order of BinData type in BSON Types reference

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: v1.3.5
    • Component/s: manual
    • Labels:
    • Last comment by Customer:
      true
    • Actual Time:
      4

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tim.slavin Tim Slavin
              Reporter:
              matt.kangas Matt Kangas
              Participants:
              Last commenter:
              Jonathan Dahl Jonathan Dahl
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                7 years, 22 weeks, 5 days ago
                Date of 1st Reply: