I am trying to understand the behavior with map / reduce.
Here's the display function:
function() { var klass = this.error_class; emit('klass', { model : klass, count : 1 }); }
And reduction function:
function(key, values) { var results = { count : 0, klass: { foo: 'bar' } }; values.forEach(function(value) { results.count += value.count; results.klass[value.model] = 0; printjson(results); }); return results; }
Then I ran it:
{ "count" : 85, "klass" : { "foo" : "bar", "Twitter::Error::BadRequest" : 0 } } { "count" : 86, "klass" : { "foo" : "bar", "Twitter::Error::BadRequest" : 0, "Stream:DirectMessage" : 0 } }
At this point, everything is fine, but here is the result of holding a read lock every 100 documents:
{ "count" : 100, "klass" : { "foo" : "bar", "Twitter::Error::BadRequest" : 0, "Stream:DirectMessage" : 0 } } { "count" : 100, "klass" : { "foo" : "bar", "undefined" : 0 } }
I saved my foo key, and the count attribute continued to grow. The problem is that everything else has become undefined .
So, why am I losing dynamic keys for my object while my count attribute is still good?
K'ao source share