Make calculating the size of a Document simpler

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API, BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Ross Lawley
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: