Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

https://gerrit.onap.org/r/c/cps/+/123682 we had to introduce a 'new' ObjectMapper to resolve issues with datatypes. The question now is if we should update the same ObjectMapper everywhere in the project or even across all CPS projects.

Object Mapper

Jackson

Jackson is tailored towards parsing larger files. According to cited benchmarks it is slower than GSON with large files and much slower with small files.

Although Jackson is slower in parsing in all use cases, we have a specific use case in which Jackson parser excels due to its ability to acknowledge the data type which it is parsing. For example in CpsDataPersistenceImpl.java in the toDataNode method, we use the Jackson Object mapper to parse fragment entity attributes to a map of objects. CPS-591 implemented a bug fix to change the parser from GSON to Jackson as GSON was reading integer values as Doubles https://gerrit.onap.org/r/c/cps/+/123682

GSON

GSON is faster than Jackson parser. However, as mentioned in the use case above, GSON is not capable of parsing well when it does not know the data type which it is parsing. It is possible to cast the incoming data to the correct datatype but it is not useful in the case where we do not know the incoming datatype. As such, in the use case mentioned above it is more practical to use the Jackson parser.


Resolution

It would make the most sense to use GSON as much as possible as it is the faster than Jackson. However the practicality of Jacksons parsing cannot be overlooked. Therefore it would make sense to use the Jackson parser in this scenario. We also don't want to have or create a Jackson parser and GSON parser object in the same file however as the memory cost is quite high.

  • GSON parser should solely be used in a class where possible.
  • In the case where the Jackson parser is necessary, the Jackson parser should be used in the whole class so that there is only one parser object created for a class. 

CPS


  • No labels