源数据:

{
"_id" : 1.0,
"name" : "abc",
"age" : 43.0,
"type" : 1.0,
"status" : "P",
"favorites" : {
"artist" : "Picasso",
"food" : "pizza"
},
"finished" : [
17.0,
3.0
],
"badges" : [
"blue",
"black"
],
"points" : [
{
"points" : 85.0,
"bonus" : 20.0
},
{
"points" : 85.0,
"bonus" : 10.0
}
]
} /* 2 */
{
"_id" : 2.0,
"name" : "abc",
"age" : 42.0,
"type" : 1.0,
"status" : "A",
"favorites" : {
"artist" : "Miro",
"food" : "meringue"
},
"finished" : [
11.0,
25.0
],
"badges" : [
"green"
],
"points" : [
{
"points" : 85.0,
"bonus" : 20.0
},
{
"points" : 64.0,
"bonus" : 12.0
}
]
} /* 3 */
{
"_id" : 3.0,
"name" : "ahn",
"age" : 43.0,
"type" : 2.0,
"status" : "A",
"favorites" : {
"artist" : "Cassatt",
"food" : "cake"
},
"finished" : [
6.0
],
"badges" : [
"blue",
"red"
],
"points" : [
{
"points" : 81.0,
"bonus" : 8.0
},
{
"points" : 55.0,
"bonus" : 20.0
}
]
} /* 4 */
{
"_id" : 4.0,
"name" : "xi",
"age" : 34.0,
"type" : 2.0,
"status" : "D",
"favorites" : {
"artist" : "Chagall",
"food" : "chocolate"
},
"finished" : [
5.0,
11.0
],
"badges" : [
"red",
"black"
],
"points" : [
{
"points" : 53.0,
"bonus" : 15.0
},
{
"points" : 51.0,
"bonus" : 15.0
}
]
} /* 5 */
{
"_id" : 5.0,
"name" : "xyz",
"age" : 23.0,
"type" : 2.0,
"status" : "D",
"favorites" : {
"artist" : "Noguchi",
"food" : "nougat"
},
"finished" : [
14.0,
6.0
],
"badges" : [
"orange"
],
"points" : [
{
"points" : 71.0,
"bonus" : 20.0
}
]
} /* 6 */
{
"_id" : 6.0,
"name" : "abc",
"age" : 43.0,
"type" : 1.0,
"status" : "A",
"favorites" : {
"food" : "pizza",
"artist" : "Picasso"
},
"finished" : [
18.0,
12.0
],
"badges" : [
"black",
"blue"
],
"points" : [
{
"points" : 78.0,
"bonus" : 8.0
},
{
"points" : 57.0,
"bonus" : 7.0
}
]
}

  

var mrr=db.users.mapReduce(
function(){
emit(this.age,this.name);
},
function(key,values){
var a=Avalues.length;

var ret={age:key,names:a};
return ret;
},
{ out: {replace:"result"}}

);
db[mrr.result].find()

mongo学习- mapReduce操作事例的更多相关文章

  1. mongo学习-group操作以及java代码

    原数据: /* 1 */ { "_id" : ObjectId("552a330e05c27486b9b9b650"), "_class" ...

  2. mongo学习- group操作

    group可以使用 $sum,$avg,$max,$min,$first,$last

  3. Java中的函数式编程(七)流Stream的Map-Reduce操作

    写在前面 Stream 的 Map-Reduce 操作是Java 函数式编程的精华所在,同时也是最为复杂的部分.但一旦你啃下了这块硬骨头,那你就真正熟悉Java的函数式编程了. 如果你有大数据的编程经 ...

  4. 4-python学习——数据操作

    4-python学习--数据操作 参考python类型转换.数值操作(收藏) Python基本运算符 数据类型转换: 有时候,可能需要执行的内置类型之间的转换.类型之间的转换,只需使用类名作为函数. ...

  5. Mapreduce操作HBase

    这个操作和普通的Mapreduce还不太一样,比如普通的Mapreduce输入可以是txt文件等,Mapreduce可以直接读取Hive中的表的数据(能够看见是以类似txt文件形式),但Mapredu ...

  6. 安装Linux系统,学习Linux操作基础

    20189230杨静怡 2018-2019-2 <移动平台开发实践>第1周学习总结 安装Linux系统内容总结 一.学习"基于VirtualBox虚拟机安装Ubuntu图文教程& ...

  7. HBase 相关API操练(三):MapReduce操作HBase

    MapReduce 操作 HBase 在 HBase 系统上运行批处理运算,最方便和实用的模型依然是 MapReduce,如下图所示. HBase Table 和 Region 的关系类似 HDFS ...

  8. springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验--异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档---jpa访问数据库及page进行分页---整合redis---定时任务

    springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验-- 异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档 ...

  9. 7.MapReduce操作Hbase

    7 HBase的MapReduce   HBase中Table和Region的关系,有些类似HDFS中File和Block的关系.由于HBase提供了配套的与MapReduce进行交互的API如 Ta ...

随机推荐

  1. 490 - Rotating Sentences

     Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input sentences ...

  2. hadoop之 YARN配置参数剖析—RM与NM相关参数

    参数均需要在yarn-site.xml中配置: 1. ResourceManager相关配置参数 (1) yarn.resourcemanager.address 参数解释:ResourceManag ...

  3. Jqmobile Secha Ionic比较

    1. Jqmobile 轻量级框架,它的语言基于 jquery 语言容易上手,运行速度快,但是没有 MVC 多人协作 开发的概念,项目比较大后 代码不易维护     (中小项目  1-2 个人开发很适 ...

  4. There is no Action mapped for namespace / and action name login. - [unknown location]

    (自己在浏览器中,直接进入项目的根目录,即 http://localhost:8080/ssh/  时便报错,web.xml文件已经配置了 欢迎页面 <welcome-file-list> ...

  5. TS/ES/PS

    数字信号实际传送的是数据流,一般数据流包括以下三种: ES流(Elementary Stream): 也叫基本码流,包含视频.音频或数据的连续码流. PES流(Packet Elementary St ...

  6. VS2017 Linux C++引用自定义的动态库

    前一篇博客讲了用系统库libpthread.so的例子,只需要在项目属性页的[C++->命令行参数]和[链接器->命令行参数]中加上对应参数(比如-pthread)即可,然后我试着引用自己 ...

  7. 文件os.path相关方法

    #!/usr/bin/python3# -*- coding: utf-8 -*-# @Time    : 2018/6/13 15:03# @File    : abspath_1.py impor ...

  8. 跟我学算法-svm支持向量机算法推导

    Svm算法又称为支持向量机,是一种有监督的学习分类算法,目的是为了找到两个支持点,用来使得平面到达这两个支持点的距离最近. 通俗的说:找到一条直线,使得离该线最近的点与该线的距离最远. 我使用手写进行 ...

  9. Tutorial: Getting Started with Spring Security

    This tutorial will cover a basic scenario where it  integrates Spring Security, using database-backe ...

  10. es6 class 了解

    ES6之class ES5中通常通过构造函数和原型的组合形式来创建对象.在ES6中引入class作为对象模板, Class定义语法 class point{ constructor(x,y){ thi ...