在MongoDB中学习Map-Reduce(Learning Map-Reduce in MongoDB)
在通过互联网搜索时,我发现可以通过map-reduce函数在mongodb中模拟连接。 浏览文档令人困惑。
我有两个集合:一个包含一个用户的朋友列表。 而另一个系列则是所有用户。 我想获取所有朋友的个人资料照片。 如何创建mongodb查询以获得所需的结果?
USERS系列:
{ "_id" : ObjectId("524c194a6e3715ce0a000001"), "email" : "qwerty@abc.com", "password" : "", "phone" : "", "salt" : "", "upic" : "someuser2fd2751259bb7519d7b760ffee9b7fce203ad1f34.jpg", "username" : "someuser2" } { "_id" : ObjectId("524be475fafb35480a000001"), "email" : "", "password" : "", "phone" : "", "salt" : "", "upic" : "amitverma2522b7a52e054c350f78fd7f3558919f2e2dab58.jpg", "username" : "amitverma" }
每个用户集合的朋友:
{ "_id" : ObjectId("526547ed2389630000000001"), "friends" : [ { "_id" : ObjectId("524be475fafb35480a000001"), "username" : "amitverma" }, { "_id" : ObjectId("524be475fafb35480a000001"), "username" : "someuser2" } ], "upic" : "macbookfd2751259bb7519d7b760ffee9b7fce203ad1f34.jpg", "username" : "someuser" }
帮助将不胜感激。
While searching through the internet, I found out that joins can be emulated in mongodb through the map-reduce function. Going through the docs was confusing.
I have two collections: one with a list of friends of one user. And the other collection is of all the users. I want to fetch the profile pictures of all the friends. how do I create a mongodb query to get the desired results?
The USERS collection:
{ "_id" : ObjectId("524c194a6e3715ce0a000001"), "email" : "qwerty@abc.com", "password" : "", "phone" : "", "salt" : "", "upic" : "someuser2fd2751259bb7519d7b760ffee9b7fce203ad1f34.jpg", "username" : "someuser2" } { "_id" : ObjectId("524be475fafb35480a000001"), "email" : "", "password" : "", "phone" : "", "salt" : "", "upic" : "amitverma2522b7a52e054c350f78fd7f3558919f2e2dab58.jpg", "username" : "amitverma" }
The friends of each user collection:
{ "_id" : ObjectId("526547ed2389630000000001"), "friends" : [ { "_id" : ObjectId("524be475fafb35480a000001"), "username" : "amitverma" }, { "_id" : ObjectId("524be475fafb35480a000001"), "username" : "someuser2" } ], "upic" : "macbookfd2751259bb7519d7b760ffee9b7fce203ad1f34.jpg", "username" : "someuser" }
Help would be appreciated.
原文:https://stackoverflow.com/questions/20153024
最满意答案
它的评论很长,所以我把它作为一个答案。
我仍然不明白你为什么要加载已加载的PARENT程序集或如何“更新”PARENT ...
如果加载了dll,通常无法卸载它。 您必须创建一个新的AppDomain才能使其正常工作。
所以我看到它,你运行你的PARENT,它加载PLUGIN,然后附加事件。
根据http://msdn.microsoft.com/en-us//library/ff527268.aspx
注册AssemblyResolve事件的处理程序时,只要运行时无法按名称绑定到程序集,就会调用该处理程序。 例如,从用户代码调用以下方法可能导致AssemblyResolve事件被引发:
AppDomain.Load方法重载或Assembly.Load方法重载,其第一个参数是一个字符串,表示要加载的程序集的显示名称(即Assembly.FullName属性返回的字符串)。
AppDomain.Load方法重载或Assembly.Load方法重载,其第一个参数是一个AssemblyName对象,用于标识要加载的程序集。
Assembly.LoadWithPartialName方法重载。
AppDomain.CreateInstance或AppDomain.CreateInstanceAndUnwrap方法重载实例化另一个应用程序域中的对象。
这意味着您必须显式加载程序集(并且无法自动执行)以触发事件。
因此,我认为PARENT的“更新”至关重要。 你怎么做呢?
编辑
根据您的编辑,我相信您的答案可以在这里找到: 如果我重建我的项目引用的dll,我是否还必须重建项目?
这个链接还提到了一些关于严格强制引用程序集版本以及如何避免它的内容。
As described in EDIT #4 the assembly event was not registered soon enough.
I solved the problem by removing PLUGINStarter and moving the assembly resolving code to the constructor of Loader.cs. Now everything resolves nicely despite wrong assembly versions.
相关问答
更多-
软件用英文怎么说[2023-07-22]
software -
教程 本教程将向您展示如何做所有事情: http : //www.slideshare.net/scentsome/eclipse-genymotion 这是原始的网站教程: https : //cloud.genymotion.com/page/doc/ 两者都完美解释 额外: Android Studio: 转到Windows和Linux上的文件/设置或Mac OS X上的Android Studio / Preferences。 选择插件并单击浏览存储库。 在Genymotion上右键单击(Mac O ...
-
考虑加载顺序...为了JIT和调用Main,它必须理解程序。 如果不加载需要特殊处理的基类,它就无法理解程序。 事件不会触发, 因为它尚未注册 (因为Main尚未启动)。 这是行不通的。 你能做到这一点的唯一方法就是拥有一个不依赖于其他任何东西的入口点。 请注意,JIT在方法启动之前完成,所以Main也不能涉及任何未知的东西。 例如,你可能会这样做: class Loader { static void Main() { // not shown: register ass ...
-
导出插件(Export a Plug-In)[2022-01-22]
您想要创建一个更新站点来部署您的插件 。 通常不应将依赖插件(如xtext运行时)直接打包到您的功能中。 如果用户检查“在安装期间联系所有更新站点以查找依赖项”,那么将直接从eclipse服务器获取您的依赖项。 You want to create an update site to deploy your plugin. Dependent plugins (like the xtext runtime) should normally not be packaged directly into your ... -
为什么AssemblyResolver即使在加载dll(manualy)时也会触发?(Why AssemblyResolver fire even when dll is loaded (manualy)?)[2022-09-28]
我发现类似的问题当Assembly在CurrentDomain中时,为什么调用AssemblyResolve? 从那里回答选择一个绑定上下文 ,其中所有内容都进行了详细描述(行列中没有列缺点 )。 我认为是这样,这是安全原因。 I find similar question Why is AssemblyResolve called when Assembly is in CurrentDomain? Answer from there follow me to Choosing a Binding Con ... -
您可以设置运行时的探测路径,以便可以找到程序集。 在您的应用程序配置文件中设置探测元素。
-
单击帮助 - >关于。 单击插件详细信息 。 你可以看到所有加载的插件。 检查checkstyle插件是否存在。 如果没有,请转到Window-> Show View - > Error LOg 。 您可以查看所有错误日志,包括checkstyle加载错误。 在做上述所有事情之前,不要忘记在安装插件后重新启动eclipse 。 或者从eclipse退出,转到eclipse文件夹并在命令提示符eclipse.exe -clear中执行bellow命令 安装和使用eclipse插件非常容易。 一旦你开始使用ec ...
-
它的评论很长,所以我把它作为一个答案。 我仍然不明白你为什么要加载已加载的PARENT程序集或如何“更新”PARENT ... 如果加载了dll,通常无法卸载它。 您必须创建一个新的AppDomain才能使其正常工作。 所以我看到它,你运行你的PARENT,它加载PLUGIN,然后附加事件。 根据http://msdn.microsoft.com/en-us//library/ff527268.aspx 注册AssemblyResolve事件的处理程序时,只要运行时无法按名称绑定到程序集,就会调用该处理程序 ...
-
AssemblyResolve没有被解雇(AssemblyResolve not fired)[2021-10-13]
您看到的行为是由可能由.NET运行时执行的方法内联引起的。 为了使您的方案有效,请确保受影响的方法未被内联。 像这样: class Bar { static Bar() { Resolver.Setup(); } public voidFoo() { _DoTheJob(); } [MethodImpl(MethodImplOptions.NoInlining)] void _DoTheJob() { var ... -
这很不明确。 但是,只有在需要触发时,AssemblyResolve才会触发,因为CLR无法单独找到该程序集。 由于通常指定程序集的完整路径名,因此在使用LoadFrom()时可能不会出现这种情况。 That's pretty unclear. But AssemblyResolve will only fire when it needs to fire because the CLR cannot find the assembly by itself. Which is somewhat likely ...