diff options
author | Eric Avdey <eiri@eiri.ca> | 2017-03-21 12:03:09 -0300 |
---|---|---|
committer | Jay Doane <jay.s.doane@gmail.com> | 2017-04-24 11:53:57 -0700 |
commit | 49fb01d6c3ce74b7f5922b4fd8be99f7bd07101c (patch) | |
tree | 7ba9d71a387821599e146cfdfd58b1a769759ab3 | |
parent | 2bc93b9a8c3c786a131c555a79e253b00f3e05f9 (diff) | |
download | couchdb-49fb01d6c3ce74b7f5922b4fd8be99f7bd07101c.tar.gz |
Adopt all_docs_reduce_to_count/1 to _local docs
We are using all_docs_reduce_to_count/1 in
_local_docs handler, but reductions got
from local btree are different from
reductions passed from id btree's enumerator.
This change converts passed local's KVs to
list of expected #doc_full_info records.
-rw-r--r-- | src/couch_mrview/src/couch_mrview_util.erl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl index 3830b96c8..27f8737d4 100644 --- a/src/couch_mrview/src/couch_mrview_util.erl +++ b/src/couch_mrview/src/couch_mrview_util.erl @@ -319,7 +319,8 @@ get_row_count(#mrview{btree=Bt}) -> {ok, Count}. -all_docs_reduce_to_count(Reductions) -> +all_docs_reduce_to_count(Reductions0) -> + Reductions = maybe_convert_reductions(Reductions0), Reduce = fun couch_db_updater:btree_by_id_reduce/2, {Count, _, _} = couch_btree:final_reduce(Reduce, Reductions), Count. @@ -833,6 +834,16 @@ maybe_load_doc(Db, Id, Val, #mrargs{doc_options=Opts}) -> doc_row(couch_index_util:load_doc(Db, docid_rev(Id, Val), []), Opts). +maybe_convert_reductions({KVs0, UserReductions}) -> + KVs = lists:map(fun maybe_convert_kv/1, KVs0), + {KVs, UserReductions}. + +maybe_convert_kv({<<"_local/", _/binary>> = DocId, _}) -> + #full_doc_info{id = DocId}; +maybe_convert_kv(DocInfo) -> + DocInfo. + + doc_row(null, _Opts) -> [{doc, null}]; doc_row(Doc, Opts) -> |