Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _approx_count_distinct as a builtin reduce function #1346

Merged
merged 12 commits into from
Jun 6, 2018
Prev Previous commit
Next Next commit
Squash 5d184152 to rebase COUCHDB-2971 work
commit 5d18415237e7a01e1ac401607f7fc36b671bf640
Author: Adam Kocoloski <[email protected]>
Date:   Thu Apr 28 15:12:44 2016 -0400

    Add a finalize step after rereduce

    Currently this is a noop for every reduce function except the HLL
    cardinately estimator implemented in _distinct.

    COUCHDB-2971
  • Loading branch information
kocolosk committed May 28, 2018
commit 02f9c010f536f84939b664aa361016d3f32a0cec
3 changes: 2 additions & 1 deletion src/fabric/src/fabric_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ get_next_row(#collector{reducer = RedSrc} = St) when RedSrc =/= undefined ->
end, Counters0, Records),
Wrapped = [[V] || #view_row{value=V} <- Records],
{ok, [Reduced]} = couch_query_servers:rereduce(Lang, [RedSrc], Wrapped),
{ok, [Finalized]} = couch_query_servers:finalize([Reduced]),
NewSt = St#collector{keys=RestKeys, rows=NewRowDict, counters=Counters},
{#view_row{key=Key, id=reduced, value=Reduced}, NewSt};
{#view_row{key=Key, id=reduced, value=Finalized}, NewSt};
error ->
get_next_row(St#collector{keys=RestKeys})
end;
Expand Down