首页 \ 问答 \ 在MongoDB中学习Map-Reduce(Learning Map-Reduce in MongoDB)

在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
更新时间:2023-02-21 09:02

最满意答案

它的评论很长,所以我把它作为一个答案。

我仍然不明白你为什么要加载已加载的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.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。