mongo学习- mapReduce操作事例
源数据:
{
"_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操作事例的更多相关文章
- mongo学习-group操作以及java代码
原数据: /* 1 */ { "_id" : ObjectId("552a330e05c27486b9b9b650"), "_class" ...
- mongo学习- group操作
group可以使用 $sum,$avg,$max,$min,$first,$last
- Java中的函数式编程(七)流Stream的Map-Reduce操作
写在前面 Stream 的 Map-Reduce 操作是Java 函数式编程的精华所在,同时也是最为复杂的部分.但一旦你啃下了这块硬骨头,那你就真正熟悉Java的函数式编程了. 如果你有大数据的编程经 ...
- 4-python学习——数据操作
4-python学习--数据操作 参考python类型转换.数值操作(收藏) Python基本运算符 数据类型转换: 有时候,可能需要执行的内置类型之间的转换.类型之间的转换,只需使用类名作为函数. ...
- Mapreduce操作HBase
这个操作和普通的Mapreduce还不太一样,比如普通的Mapreduce输入可以是txt文件等,Mapreduce可以直接读取Hive中的表的数据(能够看见是以类似txt文件形式),但Mapredu ...
- 安装Linux系统,学习Linux操作基础
20189230杨静怡 2018-2019-2 <移动平台开发实践>第1周学习总结 安装Linux系统内容总结 一.学习"基于VirtualBox虚拟机安装Ubuntu图文教程& ...
- HBase 相关API操练(三):MapReduce操作HBase
MapReduce 操作 HBase 在 HBase 系统上运行批处理运算,最方便和实用的模型依然是 MapReduce,如下图所示. HBase Table 和 Region 的关系类似 HDFS ...
- springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验--异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档---jpa访问数据库及page进行分页---整合redis---定时任务
springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验-- 异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档 ...
- 7.MapReduce操作Hbase
7 HBase的MapReduce HBase中Table和Region的关系,有些类似HDFS中File和Block的关系.由于HBase提供了配套的与MapReduce进行交互的API如 Ta ...
随机推荐
- Windows自带NAT端口映射,命令行CMD操作即可
由于有需求进行端口映射,又不想装乱七八糟的软件,Windows本身自带的路由远程访问配置太麻烦,还要两块网卡,坑爹啊. 其实Windows本身命令行支持配置端口映射,条件是已经安装了IPV6,启不启用 ...
- linux中查看nginx、apache、php、mysql配置文件路径的方法
如何在Linux中查看nginx.apache.PHP.MySQL配置文件路径了,如果你接收一个别人配置过的环境,但没留下相关文档.这时该怎么判断找到正确的加载文件路径了.可以通过以下来判断1.判断a ...
- Remi 安装源
Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护.有个这个源之后,使用 YUM 安装或更新 PHP.MySQL.phpMyAdmin ...
- laravel 控制器中使用 try catch
需要操作数据库时,当数据字段不一致,mysql报错,控制程序,需要使用try catch 下面是使用案例 $morder['morder_time'] = time();//在这里使用try catc ...
- yaml语言教程
大家直接去看阮一峰的教程. http://www.ruanyifeng.com/blog/2016/07/yaml.html?f=tt 简介 基本语法规则: 大小写敏感 使用缩进表示层级关系 缩进时不 ...
- JavaScript常见集合操作
JavaScript常见集合操作 集合的遍历 FOR循环(效率最高) 优点:JavaScript最普遍的for循环,执行效率最高 缺点:无法遍历对象 for(let i=0;i<array.le ...
- vconsole使用
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- django-渲染页面+locals
from django.shortcuts import render, redirect from django.views import View from django.http import ...
- OpenCL 事件的使用,以及回调函数
▶ 事件的两种使用方法.第一种是用事件 a 标记进入命令队列的操作 A,于是后续进入命令队列的操作 B 可以被要求等到前面事件 a 完成(即操作 A 完成)以后才能开始调度执行.第二种是使用用户自定义 ...
- 关闭 iTunes 自动同步
关闭 iTunes 自动同步 iTunes>Edit>perererset>device>Prevent iPods,iPhone, and iPads from syncin ...