GC can slow down reads esp for collections. Many HashMap are created and we suspec the MongoDB driver for Java is the creator (DBObject is a subclass of LinkedHashMap).
We could imagine not create these BObject but directly talk to the BSON stream. That would of course be a lot of work to do that right and the MongoDB driver needs to expose BSON without parsing it first.
It more a prospective idea.
as I said above, have a look at what we did for the Infinispan / Hot Rod ("infinispan remote") dialect. It's a very similar optimisation.
Ok. I will investigate your solution.
I have some results of investigation. I describe my things. Any ideas welcome!
Main problem in the method "decode" of class below
Problem is I don't know what type is loaded. It leads to problem with mapping between field "_id" and field with annotation @Id .
I see next ways:
I can prepare not fully initialized Tuple by reading BsonReader. Initialization will finished in method "getTuple" (and the like)
I can add new field "_type". But .... it leads to problem if json not contains the field
Any ideas or advises are welcome
We need some object-mediator anyway.
sure having some intermediate objects might be necessary; we want to minimize them but a couple might be acceptable - especially as a starting point.
The main idea is to avoid JSON encoding and use BSON directly to explore performance tradeoffs caused by the serialization layer.