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

Make calculating the size of a Document simpler

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API, BSON
    • None

      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;
      

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

              Created:
              Updated:
              Resolved: