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

Make calculating the size of a Document simpler

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • API, BSON
    • None

    Description

      Currently it involves a lot of code:

      BasicOutputBuffer buffer = new BasicOutputBuffer();
      BsonBinaryWriter binaryWriter = new BsonBinaryWriter(buffer);
      new DocumentCodec().encode(binaryWriter, document, EncoderContext.builder().build());
      int bsonSize = binaryWriter.getBsonOutput().getSize();
      

      Especially when compared to the legacy BSON way:

      int bsonSize = BSON.encode(document).length;
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: