上下文之间的区别是什么?map_query qry。在Appengine map_async NDB ?

时间:2020-11-29 23:12:46

The documentation seems to suggest that they can be used similarly. What is the difference and when should each be used? Which should be used for optimum performance (as both suggest that they are the "fastest").

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

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

文档上下文。map_query:https://docs.google.com/document/d/1rPyB2RmRERAZDPpqy2cxzXeDGyfLhX-s-3dFVpnwFXw/edit?hl=en_US标题= h.wniiq5a4ja4o

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

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

2 个解决方案

#1


2  

Definitely use qry_obj.map_async(). Context().map_query() is a lower-level API that you shouldn't need. Note, that document is way out of date; I have a TODO to update it but other things keep getting priority. Fortunately the Google App Engine documentation team is helping out with documentation now.

当然使用qry_obj.map_async()。Context().map_query()是一个不需要的低级API。注意,那个文件已经过时了;我要做的是更新它,但是其他的事情总是优先。幸运的是,谷歌应用程序引擎文档团队正在帮助编写文档。

#2


1  

Looking at the implementation it appears Query.map_async is just a shortcut to call Context.map_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)

#1


2  

Definitely use qry_obj.map_async(). Context().map_query() is a lower-level API that you shouldn't need. Note, that document is way out of date; I have a TODO to update it but other things keep getting priority. Fortunately the Google App Engine documentation team is helping out with documentation now.

当然使用qry_obj.map_async()。Context().map_query()是一个不需要的低级API。注意,那个文件已经过时了;我要做的是更新它,但是其他的事情总是优先。幸运的是,谷歌应用程序引擎文档团队正在帮助编写文档。

#2


1  

Looking at the implementation it appears Query.map_async is just a shortcut to call Context.map_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)