Mongodb Mapreduce给出错误

编程入门 行业动态 更新时间:2024-10-22 19:38:41
本文介绍了Mongodb Mapreduce给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在mapreduce中有一组数据.1000000条记录,用于收集随机表格数据. 数据结构如下:

I have a set of data in mapreduce.. 1000000 records for random formdata collected.. The data structure is as follows :

{ "_id" : ObjectId("4d9c8318cbb7813ef940d9e6"), "clientid" : 5, "FormData" : { "emailadress" : "SWV" } } { "_id" : ObjectId("4d9c8318cbb7813efb40d9e6"), "clientid" : 4, "FormData" : { "key1" : "VCYU", "key" : "PJO" } } { "_id" : ObjectId("4d9c8318cbb7813efc40d9e6"), "clientid" : 4, "FormData" : { "key1" : "NJ", "key" : "BZ" } } { "_id" : ObjectId("4d9c8318cbb7813efd40d9e6"), "clientid" : 2, "FormData" : { "last" : "AY", "first" : "B" } } { "_id" : ObjectId("4d9c8318cbb7813e0041d9e6"), "clientid" : 4, "FormData" : { "key1" : "X", "key" : "QPIQ" } } { "_id" : ObjectId("4d9c8318cbb7813e0241d9e6"), "clientid" : 5, "FormData" : { "emailadress" : "K" } } { "_id" : ObjectId("4d9c8318cbb7813e0341d9e6"), "clientid" : 2, "FormData" : { "last" : "EJ", "first" : "K" } } { "_id" : ObjectId("4d9c8318cbb7813e0441d9e6"), "clientid" : 5, "FormData" : { "emailadress" : "X" } } { "_id" : ObjectId("4d9c8318cbb7813e0541d9e6"), "clientid" : 2, "FormData" : { "last" : "B", "first" : "G" } } { "_id" : ObjectId("4d9c8318cbb7813e0641d9e6"), "clientid" : 4, "FormData" : { "key1" : "BWUE", "key" : "UJ" } } { "_id" : ObjectId("4d9c8318cbb7813e0741d9e6"), "clientid" : 2, "FormData" : { "last" : "Q", "first" : "K" } } { "_id" : ObjectId("4d9c8318cbb7813e0941d9e6"), "clientid" : 5, "FormData" : { "emailadress" : "IRH" } } { "_id" : ObjectId("4d9c8318cbb7813e0b41d9e6"), "clientid" : 5, "FormData" : { "emailadress" : "VCMYE" } } { "_id" : ObjectId("4d9c8318cbb7813e0c41d9e6"), "clientid" : 2, "FormData" : { "last" : "LZ", "first" : "L" } } { "_id" : ObjectId("4d9c8318cbb7813e0d41d9e6"), "clientid" : 2, "FormData" : { "last" : "X", "first" : "YS" } } { "_id" : ObjectId("4d9c8318cbb7813e0e41d9e6"), "clientid" : 2, "FormData" : { "last" : "IA", "first" : "QT" } } { "_id" : ObjectId("4d9c8318cbb7813e1041d9e6"), "clientid" : 2, "FormData" : { "last" : "GZ", "first" : "MM" } } { "_id" : ObjectId("4d9c8318cbb7813e1141d9e6"), "clientid" : 3, "FormData" : { "phonenumber" : "G", "userid" : "KU", "key" : "KQ" } } { "_id" : ObjectId("4d9c8318cbb7813e1241d9e6"), "clientid" : 3, "FormData" : { "phonenumber" : "E", "userid" : "NU", "key" : "ZHP" } } { "_id" : ObjectId("4d9c8318cbb7813e1341d9e6"), "clientid" : 4, "FormData" : { "key1" : "FUYV", "key" : "GZ" } }

我的地图功能是

function () { this.FormData.forEach(function (z) {emit(this.clientid, {count:1, datalength:1});}); }

我的reduce函数是:

My reduce function is :

function (key, vals) { var result = {count:0, datalength:0}; vals.forEach(function (value) {result.count += value.count;result.datalength = value.datalength;}); return result; }

当我运行db.clientdata.mapReduct(m,m2)时我得到

When i run db.clientdata.mapReduct(m,m2) i get

Wed Apr 6 15:09:35 uncaught exception: map reduce failed: { "assertion" : "map invoke failed: JS Error: TypeError: this.FormData.forEach is not a function nofile_b:1", "assertionCode" : 9014, "errmsg" : "db assertion failure", "ok" : 0 }

任何人都可以帮忙吗?

预先感谢

推荐答案

如果计数和数据长度具有相同的值,为什么还要使用它们呢?似乎您只需要使用count.

Why are you using count and datalength if they have the same value? Seems like you just need to use count.

地图功能:

function () { emit(this.clientid, {count:1}); }

减少功能:

function (key, vals) { var result = {count:0}; vals.forEach(function (value) {result.count += value.count;}); return result; }

更多推荐

Mongodb Mapreduce给出错误

本文发布于:2023-10-28 01:15:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535068.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Mongodb   Mapreduce

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!