[JAVA-2417] Add uset a mark and multiple marks in BSONReader Created: 22/Dec/16  Updated: 22/Dec/16  Resolved: 22/Dec/16

Status: Closed
Project: Java Driver
Component/s: BSON, Codecs
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Roy Rim Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-2416 BSONReader mark - add support to unse... Closed

 Description   

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.



 Comments   
Comment by Jeffrey Yemin [ 22/Dec/16 ]

This duplicates JAVA-2416.

Generated at Thu Feb 08 08:57:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.