MB-9467 Enforce max total KV size that can be emitted per doc/view

To avoid consuming too much memory while running a single map function,
enforce a maximum limit for the total amount of data that can be emitted
per document and per view. This limit is configurable via the couch_config
option "max_kv_size_per_doc", section "mapreduce", and corresponds to the
sum of the byte size of all emitted keys and values.

A value of 0 for this new setting, disables the limit (meaning unlimited,
as before this change).

So far, before any memory blowup could happen, the function execution was
aborted due to the trigger of the timeout, such as in the following example
case:

function(doc, meta) {
    for (var i = 0; i < 1000000; i++) {
        for (var j = 0; j < 1000000; j++) {
            emit(doc.value, null);
        }
    }
}

However, one user was able to get V8 heap exhaustion while running a map
function. Despite unsuccessful attempts so far to reproduce the heap
exhaustion issue, this change allows to enforce sane limits.

Change-Id: I4af03208027868a461c568dcd20ff49bec27ed76
Reviewed-on: http://review.couchbase.org/30055
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>