add couch_mrview:view_changes_since/{6,7} function

This function add the possibility to get changes in a view since the
last upddated sequence. You can all changes in a view since a sequence
or all changes for a key or a range in a view.

The following new secondaries are created to allows this feature:

- a generic log index to log the latest changes in views for a docid :
{DocId, [{ViewId, {Key, Seq, OP}}]} where OP can be del or add. This
index allows us to mark a key as removed if needed. It will be useful
later to help us to chain map/reduces operations or such things.

- a seq index associated to a view id : {ViewId, [{Seq, Key}, {DocId, Val}]} to look for all changes in a view

- an index indexing keys by seq: {ViewId, [{[Key, Seq], DocId}, Val}]},
  to looks for changes associated to a key or a ranhge

Note: all deleted keys are marked as deleted in the log index and their
value is {[{<<"_removed">>, true}]}.

To start to index changes you need to pass the options {seq_indexed:
true} to the design document.

Caveat: when the changes are indexed the size of the index is significantly higher.

Example of usage:  https://www.friendpaste.com/5Y6gihQReaxd8ERqbDom3y

Conflicts:
	src/couch_mrview_updater.erl
	src/couch_mrview_util.erl
couch_mrview: fix purge when seq_indexed=true

This change makes tsure to also purge the log btree and related btrees
in views when seqs_indexed is set to true.
couch_mrview: fix changes log

This changes make sure we pass correct keys to remove to the seq and
key_byseq btrees in views.
couch_mrview: add couch_mrview:count_view_changes_since/{4,5}

Add function to couch changes in a view index, similar to
couch_db:count_changes_since/2 .

Conflicts:
	src/couch_mrview.erl
couch_mrview: add view changes test

test view changes and fix errors.
couch_mrview: check removed keys from the index.
couch_mrview: add couch_mrview:refresh/2 function

function to refresh a view index.

Conflicts:
	src/couch_mrview.erl
add index update events notifications

Conflicts:
	src/couch_mrview_updater.erl
couch_mrview: couch_mrview_changes:handle_changes

Similar to couch_changes:handle_changes but for view changes. It add
support for longpolling, normal and continuous stream The API differs
from the one for doc by beeing independant from the transport: the
support of HTTP will be added on top for example.

This API will be also used to replace the view filter in the current _changes
API.

Also add unittests.
add supports of view changes in the _changes API

Now when the option `seq_indexed=true` is set in the design doc, the
view filter in _changes will use it to retrieve the results. Compared to
the current way, using a view index will be faster to retrieve changes.
It also gives the possibility to filter changes by key or get changes in
a key range. All the view options can be used.

Note 1: if someone is trying to filter a changes with view options when
the views are not indexed by sequence, a 400 error will be returned.
Note 2: The changes will only be returned when the view is updated if
seq_indexed=true

Conflicts:
	src/couch_mrview_http.erl
couch_index: add background indexing facility

This change add the possibility to trigger a view indexation in
background. The indexation can only work in background if at least one
process acquired it using the `couch_index_server:acquire_index/3`
function. If all the process that acquired it are down or released it
using `couch_index_server:release_indexer/3` then the background task is
stopped.

By default the background indexation will happen every 1s or when 200
docs has been saved in the database. These parameters can be changed
using the options `threshold` and `refresh_interval` in the couch_index
section.

To use it with couch_mrview a new option {refresh, true} has been added
to couch_mrview_changes:handle_changes Also the query parameter
refresh=true is passsed in t the HTTP changes API.
couch_mrview: fix 10-index-changes.t

proper test to check the indexer.
couch_mrview: add API to retrieve view info.

Add couch_mrview:get_view_info/3 to retrieve the internal informations
of a view like the last update seq in this view or the number of rows.

Conflicts:
	src/couch_mrview.erl
	test/04-index-info.t
couch_mrview: add HTTP handler to retrieve the infos on a view.
couch_replicator: add replication using changes in a view

Instead of a database, the replicator can now filter the documents using
a view index. All documents having a key emitted in the view can be
replicated.

View parameters can be used. Which means that you can replicate results
corresponding to a key in a view or a range.
use ERL_FLAGS instead of a shebang to launch tests

Conflicts:
	test/03-red-views.t
fix case clause
add /<db>/_design/<ddocname>/_reindex handler

When you 'POST' on the _reindex handle all the views of the group will
be reindexed.

close #RCOUCH-36
extract couch_httpd changes API in its own module

Conflicts:
	src/couch_mrview_updater.erl
Add preliminary version of view changes