Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1262

Support a binary bson type that can accept a byte array "slice"

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • BSON
    • None

    Description

      The current Binary type contract is to pass in a byte array that represents exactly the data to be saved. It would be nice to be able to express a slice/window of a byte array by also accepting offset and length inputs that are used to calculate the relevant portion of the byte array. This is obviously a performance optimization to help avoid copies in performance sensitive parts of a system.

      Justification:
      In streaming interfaces it is generally not known how big a binary payload will be. Thus something like a `ByteArrayOutputStream` is used, and even when an implementation provides direct access to the underlying buffer, it's not possible[1] to construct a specially sized byte array for the Binary type without a copy.

      [1] I'm totally unfamiliar if java offers a way to unsafely trim a byte array, so my claim is speculation.

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: