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

Add uset a mark and multiple marks in BSONReader

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: BSON, Codecs
    • None

      It would be great if a mark set on a org.bson.BsonReader could be unset. Right now only resetiing to the mark(ed) position is possible.

      My use case(s):

      I wrote a reflection based org.bson.codecs.Codec that uses the new MongoDB java driver. Within the mongo database any inserted entity holds a field with the type (or name or...) of the correct Java-Pojo this entity maps to. When reading entities from the mongo I first need to read that type-property, then I create the java-Pojo instance and then I reset the mark to re-read all remaining fields into the newly created Java-instance. I am aware of the fact that I could have used the DocumentCodec provided by the mongo driver for that purpose but this would imply double conversion hence double work hence less performance.

      Now, in most cases the first field read IS actually the type and I do not reset the mark. In this case I would like to unset the mark.

      While decoding any decoder may internally mark the reader itself in order to apply logic as described above. Unfortunately the BsonReader is not capable of setting more than one mark at a time.

      My desired behaviour would be: Any mark set can be reset and unset. All marks could be put on a stack?!

      The main issue here is, that I cannot be sure that I don’t know if the nested decoder uses mark itself.

            Assignee:
            Unassigned Unassigned
            Reporter:
            roy.rim@mongodb.com Roy Rim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: