Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57726

ZigZag encoder/decoder for signed 32bit and 64bit integer

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Execution Team 2021-06-28, Execution Team 2021-07-12
    • 0

      Add a "ZigZag" encoder for signed integers that stores the sign bit as the least significant bit. Two's complement is using the most significant bit resulting in a large bit difference for -1 vs 0.

      With ZigZag, Simple-8b encoder does then not have to know about signed integers and can treat everything as unsigned.

      For 32bit integers ZigZag encoding would look like this:
      zigzag = (n << 1) ^ (n >> 31)

            Assignee:
            luke.bhan@mongodb.com Luke Bhan (Inactive)
            Reporter:
            jackson.xie@mongodb.com Jackson Xie (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: