CBD-422 More efficient approach to build initial index

Change-Id: I39cd653b4c166007e9555da1a52eda1e7240e2fc
Reviewed-on: http://review.couchbase.org/13671
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
MB-100 Fix indentation of base64 function blob

4 spaces indentation and not too long lines, like everywhere
else.

Change-Id: I1f5850efefe4202c7f68c20ea8084f45e41ba186
Reviewed-on: http://review.couchbase.org/18547
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
MB-100 Validate function argument is a string

To prevent odd runtime issues, verify that the input to
the base64 JavaScript function is in fact a string.

$ node
> var foo = {};
> var foo2 = 123;
>
> foo.length % 4 > 0
false
> foo2.length % 4 > 0
false
>

Change-Id: If7d27203125c02b138e11881c8878befc8022fad
Reviewed-on: http://review.couchbase.org/18548
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-425 Improve dynamic error reporting for reduce functions

1) Log errors from builtin reduce/rereduce calls as well

2) Log reduce/rereduce errors from old couch views as well

3) A bit less erlang term stringified errors in view merge errors
   (more human readable)

Change-Id: Iee85ad8a3f8cbd9e398e177d3c6f7ce4795898f8
Reviewed-on: http://review.couchbase.org/18592
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
MB-100 Remove outdated code/comment

No longer needed.

Change-Id: I28fe4abdab1027d5491e98de178247d146834e3d
Reviewed-on: http://review.couchbase.org/18686
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-456 Separate document body and meta arguments to map function

Sends non-JSON values as byte arrays for the 'doc' argument.
Numbers and ascii text can be decoded trivially from this capability,
extending our support for legacy applications.

The document JSON format on the wire for the Admin server client
looks like this now:

    {
      "body":{"user":"data","_anything":"goes"},
      "meta":{"id":"mydocid"}
    }

Turns off support for _id lookups in include_docs queries, although
with server level include docs going away as well, this change should
be of little consequence. Include_docs is  not removed as it is used
heavily by tests, in the future it  will be renamed to x_include_docs
across both tests and query  parser, in order to reflect the non-
supported nature.

Ticket with the specifications document:
http://www.couchbase.com/issues/browse/CBD-456

Admin UI and ns_server changes are in this change:
http://review.couchbase.org/#change,18028

Depends on this change in testrunner for view tests:
http://review.couchbase.org/#change,17768

Squashed in an old patch: http://review.couchbase.org/#change,18111

TODO: EP engine doesn't need to check for _fields when  setting JSON
flag. This can be accomplished in a future patch.

Related issue (not addressed by this patch): views and _all_docs
output (as well as XDCR JSON format) needs to understand non-UTF8
keys: http://www.couchbase.com/issues/browse/CBD-453

Change-Id: Ic8e3c5be07bd59b08f618b6f735e46c96ee4c9f2
CBD-456 Alter couch tests to use the new doc format

This moves the tests over to the new JSON format.

Change-Id: Ife4315db7cb2b1ffb22da0b7bfabd4f60b43c4cf