Google App Engine 上的 Protocol Buffers 与 JDO
我正在开发一个将从 GAE 获取数据的移动应用程序,并且我正在尝试在使用 Protocol Buffers 和 JDO 之间做出决定。首先,我不知道如何让 PB 持久。我知道这只是 JDO 注释标签的问题。
我还看到了这个帖子,其中他们警告说 PB 数据无法编入索引。不过,我不确定这对我来说是否是个问题。有没有一种折中办法,比如使用 JDO 进行持久化,但使用 PB 进行通信?
谢谢
编辑:听起来最初的考虑是一个坏主意,但我仍然想知道我是否可以从仅使用 PB 向客户端传输数据中获得好处。将 JDO 对象转换为 PB 对象以传输到客户端的开销会超过 PB 的好处吗?事实上,听起来这正是 GAE 内部发生的事情,无论如何,所以这可能意味着这是一个很好的方法......
I'm working on a mobile app that will get data from GAE, and I'm trying to decide between using Protocol Buffers and JDO. First off, I'm not sure how to make PBs persistent. I know it's just a matter of the annotation tags with JDO.
I also saw this thread where they warn that PB data can't be indexed. I'm not sure if that's a problem for me or not, though. Is there a happy medium, like a way to use JDO for persistence, but use PB for communication?
Thanks
Edit: Sounds like the initial consideration was a bad idea, but I'm still wondering if I can get the benefit of using PBs just for transmitting data to the client. Would the overhead of converting JDO objects to PB objects for transmission to the client outweigh the benefits of PBs? Actually, it sounds like that's exactly what happens internally on GAE, anyway, so that probably means it's a good way to go...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来参加这里的聚会很晚了,但答案是“视情况而定”。 :-D
JDO 的优点是它与 Java 的互操作性极强,而且它直接内置于 App Engine 中。开箱即用,这是很难被超越的。
协议缓冲区的优点是非常高效并且可以在多种语言中工作 - Google 支持 Java、Python、C++,但是有一个 第三方支持的其他语言的巨大列表。而且它们是可扩展的并且非常易于维护。
正如您所指出的,JDO 对象由 App Engine 自动索引,尽管您可以非常简单地构建自己的索引,但很难丢失它。
坦率地说,这些天我使用协议缓冲区语言作为数据定义语言,但大多数东西都以 JSON 形式发送——它们只有在需要大量存储它们时才会转换回原型,这样我就可以节省大量成本......
Coming very late to the party here, but the answer is "it depends". :-D
JDO has the advantage that it's extremely interoperable with Java up and down the line and it's built right into the App Engine. For having it work right out of the box, that's hard to beat.
Protocol buffers have the advantage of being awesomely efficient and working in a lot of languages - Java, Python, C++ are supported by Google, but there's a huge list of other languages supported by third-parties. And they're extensible and very easy to maintain.
As you point out, JDO objects are automatically indexed by the App Engine, it'd be hard to lose that, though you can probably build your own index quite simply.
I frankly these days use the protocol buffer language as a data definition language, but have most things sent around as JSON - they only get converted back to protos when it comes time to store them en masse and I can get huge savings...