I am trying to run a map-reduce and it is failing with the following
error :
/usr/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/db.rb:520:in
`command'': Database command ''mapreduce'' failed:
(errmsg: ''assertion:
assertion scripting/engine_spidermonkey.cpp:433''; ok:
''0.0'').
(Mongo::OperationFailure)
from /usr/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/
collection.rb:618:in `map_reduce''
from unique-sites.rb:164
The map reduce works okay if a smaller dataset is provided. Can
someone please help ?
Thanks
Pankaj
HEre are the map and reduce functions:
map = "function() { if ( this.sites ) " +
"{ " +
" var parent_deviceid=this.deviceid; "+
" var unique_total_dur = new Object(); " +
" this.sites.forEach(function(site_entry) { " +
" var validDur = 0; "+
" if ( site_entry.duration ) "+
" validDur = site_entry.duration; "+
" if ( site_entry.url in unique_total_dur ) " +
" unique_total_dur[site_entry.url] +validDur;
"+
" else { " +
" unique_total_dur[site_entry.url] = 0; "+
" unique_total_dur[site_entry.url] +validDur;
"+
"}}); " +
" for( var visited_site in unique_total_dur ) { "
+
"emit({ site: visited_site,deviceid:
parent_deviceid}, " +
"{ duration:
unique_total_dur[visited_site], count : 1} ); "+
"}" +
"}" +
" };"
Reduce
reduce = "function(key, values) { " +
"var total_sess_per_device = 0; "+
"var total_duration = 0; "+
"values.forEach(function(doc) { " +
" total_sess_per_device += doc[''count'']; "+
" total_duration += doc[''duration'']; "+
"});" +
" return { duration: total_duration, count:
total_sess_per_device }; "+
"};"
Each element in the collection looks something like this :
{
"device" : "m2",
"deviceid" : "F46F7A40C1515D025F7386AFC75EB059",
"domains" : [
{
"duration" : 25,
"end_time" : 1316644647,
"domain" : "www.pankajk.com",
"start_time" : 1316644622
}
],
"sites" : [
{
"duration" : 25,
"end_time" : 1316644647,
"url" : "https://www.pankajk.com/ServiceLogin",
"start_time" : 1316644622
}
],
}
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.