Google App Engine 上的 Protocol Buffers 与 JDO

发布于 2024-09-28 15:13:29 字数 499 浏览 0 评论 0原文

我正在开发一个将从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗酒趁年少 2024-10-05 15:13:29

来参加这里的聚会很晚了,但答案是“视情况而定”。 :-D

  1. 你的主要目标是什么?从更大的角度来看,你想实现什么目标?
  2. 您有多少数据?您存储了多少个对象?大约有多少字节?
  3. 是否有很多小物体、一些大物体,还是所有不同类型的物体?
  4. 您尝试使用哪些编程语言来使用您的数据?
  5. 您的主要资源限制是什么?您是否受到 RAM、CPU 或网络带宽的限制?
  6. 您与供应商的关系如何?

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

  1. What are your prime goals? What are you trying to achieve in the larger picture?
  2. How much data do you have? How many objects are you storing? Approximately how many bytes?
  3. Are there lots of little objects, a few large objects, or all different types?
  4. In what programming languages are you trying to use your data?
  5. What is your primary resource constraint? Are you RAM-bound, or CPU-bound, or network-bandwidth bound?
  6. What are your relationships with the vendors?

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文