Optimal way to convert XML to Objects

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I'm creating an app on Google App Engine using Java, which accepts a standard XML file and maps it to an object- which is then saved to the datastore.

I'm expecting quite a bit of entries/day (about 500+).. What is the optimal way of serializing xml, considering the cost in CPU and Data quotas of GAE/j?

回答1:

If your view of optimal is the simplest way of serialising/deserialising (and in this instance I suggest it is), then take a look at XStream, which can convert POJOs to/from XML without any annotations/interface requirements etc.



回答2:

Let's imagine you get 86,400 entries in a day - over 100 times as much as the 500 you mention. That's still only one per second, on average - and a second is a very long time in CPU terms. Of course, if each of these XML files is several gigabytes in size, then 500 of them is going to be quite a lot to handle. How big are these files likely to be?

Basically, this sounds like a non-problem. Find the simplest code you can (which will depend on what else you're doing), work out a budget in terms of how much CPU and data you're content to use, and then benchmark what you've got to decide whether it's good enough or not.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!