Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-1334

Always serialize integer types that are not BSON types as consistent types

    XMLWordPrintable

Details

    • Improvement
    • Status: Backlog
    • Unknown
    • Resolution: Unresolved
    • None
    • bson-4.0.0
    • None

    Description

      Currently, for Swift integer types besidesĀ Int32 and Int64, the BSON type an integer is encoded to varies:

      • On 64-bit platforms, Int is encoded as an Int64, and on 32-bit platforms as an Int32. This matches the fact that the bit width of Swift {{Int}}s varies depending on whether the platform is 32 or 64-bit.
      • For all other integer types e.g. UInt64, we encode them into the smallest BSON integer type that can fit the value. In some cases this results in a consistent mapping (e.g. UInt8 is always encoded as Int32), but in other cases such as e.g. {{UInt64}}s the value maybe encoded as either type.

      From the survey of drivers conducted in DRIVERS-1901, it seems most drivers tend toward consistency over space-saving. We should consider whether this is worth doing in our next BSON major release.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kaitlin.mahar@mongodb.com Kaitlin Mahar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: