源数据:

{
"_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. Jmeter监控服务器的CPU

    1.Jmeter监控服务器的软件:链接: https://pan.baidu.com/s/1Ag75IXqR2XMe8RpZA4nvHg 密码: yki2 2.(1)Window版本 <1> ...

  2. 爬取爱奇艺电视剧url

    ----因为需要顺序,所有就用串行了---- import requests from requests.exceptions import RequestException import re im ...

  3. XSS 与 CSRF 两种跨站攻击

    在前几年,大家一般用拼接字符串的方式来构造动态 SQL 语句创建应用,于是 SQL 注入成了很流行的攻击方式, 但是现在参数化查询 已经成了普遍用法,我们已经离 SQL 注入很远了.但是历史同样悠久的 ...

  4. KMP算法解释

    给定两个字符串A,B,判断T是否为S的子串(变式:寻找子串B在串A中的位置). 要求一个O(|A|+|B|)的做法. 通常称A为目标串(或主串),B为模式串. 算法过程: 我们假设串A的长度为n,串B ...

  5. android基于adb的性能测试

    应用CPU.内存.点亮.流量等数据,是应用测试的重要性能指标.本次以UC浏览器为例. 当前UC测试中,每个正式版本都会专门做一轮性能测试,测试数据包括: 1小时内存数据 1小时CPU数据 24小时电量 ...

  6. Ansible Jinja if 生成不同的MySQL文件

  7. 《OpenCL异构并行编程实战》补充笔记散点,第一至四章

    ▶ 总体印象:适合 OpenCL 入门的书,有丰富的代码和说明,例子较为简单.先把 OpenCL 代码的基本结构(平台 → 设备 → 上下文 → 命令队列 → 创建缓冲区 → 读写缓冲区 → 编译代码 ...

  8. 串口通信,帧与帧之间的时间间隔问题?9600波特率,帧将各在20ms以上

  9. 回到顶部最简单的JQuery实现代码

    CSS代码,使用了fixed让对象固定于浏览器窗口: top{position:fixed;bottom:0;right:10px;} jQuery代码,注意正常使用的几个条件:$('#top').c ...

  10. cannot nest '/dubboService/src/main/resources' inside '/dubboService/src/main' .To enable the nesting exclude '/resources' from '/dubboService/src/main'

    eclipse Maven--->update Project时出现以上错误: cannot nest '/dubboService/src/main/resources' inside '/d ...