Feature request, optionally return indexed values with keys

When a 2i query's results are a list of keys. This change adds
an optional request parameter to pb and http that, when set, will
cause pairs of `key:index_value` to be returned as the result of
a 2i query.

Has no effect on MapReduce. Uses capabilities for rolling upgrade
situations.
Add pagination to 2i results

Adds a `max_results` option to PB and HTTP 2i endpoints for limiting
the number of results returned for a 2i query.  Will return an opaque
`continuation` if there are at least `max_results` results returned. A
subsequent query that includes the `continuation` as a parameter will
return the next `max_results` results.

The results will be returned sorted ascending. In the case of $key
and $bucket queries, and equals queries, the results will be sorted by
primary key In the case of range queries the results will be sorted by
index value. Since the values must be returned from the backend for
sorting, there is a further option `return_terms` that will cause the
indexed terms to be returned to the user also, where relevant (range
queries on index fields.)

Sorting is performed by the module `sms.erl` originally written by Reid
Draper. It is used as a buffer by `riak_kv_index_fsm`.

A new vnode function `stop_fold` has been added so the fsm can tell
the backend to break out of the fold when enough results have been
gathered.

The option to stream 2i results has also been added. Adding the
`stream` option to either HTTP or PB queries will cause the API
endpoints to return chunks of results as they are received from the
fsm This can lead to much lower perceived latencies as the application
recieves the first results of a large set much sooner.

An example HTTP query: `curl
"http://127.0.0.1:10018/buckets/2ibucket/index/field2_int/1/100?return_terms=true"`
Will return the first 100 {value, key} pairs for the `field2_int`
index, sorted by value.  If there are 100 results returned, it will
also return an opaque `continuation` that may be sumbitted to continue
the query: `curl
"http://127.0.0.1:10018/buckets/2ibucket/index/field2_int/1/100?return_terms=true&continuation=some_gibberish_looking_value"`
A further `continuation` maybe returned with the results.
Remove lager info message

Spotted lager info message left over from dev, excised it.
Streaming 2i results for HTTP was broken

I have no idea how. Tests passed, then they didn't. I guess a
rebase went wrong.
WIP fold objects over bucket for riak cs
WIP add return_body support for riak_cs
WIP fix typo of indexes / index that meant $key/$bucket never match
Don't populate index record with bucket name as start and end term

We use keys for the range on buckets
Add return body option for riak cs bucket folds
Remove stray debugging lager info message
Fix bug where legacy queries never match in eleveldb

The wrong paramter was used to match in the function head for
to_first _key
Upgrade legacy queries to cut down the number of `index` fun heads
Add cs return body support to `memory` backend

Even though not required, backend feature parity makes sense,
more so if the features are to be added to `backend_eqc`.

Refactor `index | object _key_in_range` funs for common use.
Removed stray debugging `lager:info/1` message.
Add EQC test for sms (merge sort) module
Fix 2 edge cases found during testing

* Allow add_results to be called repeatedly with done, it's harmless.
* Allow sms to be called when all sources are done without crashing.
Consider key and term in concert when deciding if an item is in range

A bug found by @EngelSanchez, where `start_incl` being false
(when using a continuation, for example) led to in range values
being excluded as the key was checked in isolation.
Address many review comments (see body of commit message)

Clean-up and slightly optimise the index fsm to not recalculate
the same list length more than once. Shortcut sending the `stop_fold`
message where possible (i.e. when we notice the have enough results).

Add JSON error to 2i HTTP strem
Update all copyright notices
Normalise boolean paramters to strict true | false
Rename key fold to general fold, since it does objects too now
Merge remote-tracking branch 'origin/eas-add-sms-eqc' into pt29-2i-pagination
Merge branch 'master' into pt29-2i-pagination

Conflicts:
	src/riak_kv_app.erl