【问题标题】:What's the difference between context.map_query and qry.map_async in Appengine's NDB?Appengine 的 NDB 中的 context.map_query 和 qry.map_async 有什么区别?
【发布时间】:2012-01-08 18:32:20
【问题描述】:

文档似乎表明它们可以类似地使用。有什么区别,什么时候应该使用?应该使用哪个以获得最佳性能(因为两者都表明它们是“最快的”)。

context.map_query 的文档:https://docs.google.com/document/d/1rPyB2RmRERAZDPpqy2cxzXeDGyfLhX-s-3dFVpnwFXw/edit?hl=en_US#heading=h.wniiq5a4ja4o

qry_obj.map_async 的文档:https://docs.google.com/document/d/1rPyB2RmRERAZDPpqy2cxzXeDGyfLhX-s-3dFVpnwFXw/edit?hl=en_US#heading=h.t1t6424hbp7y

【问题讨论】:

标签: database google-app-engine asynchronous app-engine-ndb


【解决方案1】:

一定要使用 qry_obj.map_async()。 Context().map_query() 是您不需要的较低级别的 API。请注意,该文件已过时;我有一个 TODO 来更新它,但其他事情一直优先。幸运的是,Google App Engine 文档团队现在正在帮助编写文档。

【讨论】:

    【解决方案2】:

    查看implementation 似乎Query.map_async 只是调用Context.map_query 的快捷方式:

    def map_async(self, callback, merge_future=None, **q_options):
       """Map a callback function or tasklet over the query results.
    
       This is the asynchronous version of Query.map().
       """
       return tasklets.get_context().map_query(self, callback,
                                               options=_make_options(q_options),
                                               merge_future=merge_future)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 2016-06-07
      • 2016-12-11
      • 2011-11-10
      • 2012-08-26
      • 2016-07-30
      • 2023-04-06
      相关资源
      最近更新 更多