Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2022

Don't Marshal bson.Raw values in transformAndEnsureID()

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 1.5.2
    • Component/s: Performance
    • Labels:
      None

      I'm looking at optimizations that can be made for mongorestore.

      Since we insert raw BSON, I don't think we need to run bson.MarshalAppendWithRegistry() in transformAndEnsureID(). It would be nice to skip this if val holds a value of type bson.Raw or []byte and just set doc = val.

      This does mean that if the original value doesn't have an _id field, we could end up mutating val. This can't happen for mongorestore, but would be unwanted potential behavior. Perhaps we can copy val only if we are about to mutate its array.

      This would avoid copying data unnecessarily if we don't need to do so.

            Assignee:
            Unassigned Unassigned
            Reporter:
            tim.fogarty@mongodb.com Tim Fogarty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: