You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/07/23 20:13:31 UTC
[couchdb] 22/25: Support the `keys` option
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch prototype/views
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2f26a949c25e332d78f3502fe5d0c7136af76c1c
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Jul 23 14:25:09 2019 -0500
Support the `keys` option
---
src/couch_views/src/couch_views_reader.erl | 37 ++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/src/couch_views/src/couch_views_reader.erl b/src/couch_views/src/couch_views_reader.erl
index 25144ba..c26b313 100644
--- a/src/couch_views/src/couch_views_reader.erl
+++ b/src/couch_views/src/couch_views_reader.erl
@@ -31,7 +31,6 @@ read(Db, Mrst, ViewName, UserCallback, UserAcc0, Args) ->
} = Mrst,
ViewId = get_view_id(Lang, Args, ViewName, Views),
- Opts = mrargs_to_fdb_options(Args),
Fun = fun handle_row/4,
try
@@ -43,19 +42,25 @@ read(Db, Mrst, ViewName, UserCallback, UserAcc0, Args) ->
Acc0 = #{
db => TxDb,
skip => Args#mrargs.skip,
- mrargs => Args,
+ mrargs => undefined,
callback => UserCallback,
acc => UserAcc1
},
- Acc1 = couch_views_fdb:fold_map_idx(
- TxDb,
- Sig,
- ViewId,
- Opts,
- Fun,
- Acc0
- ),
+ Acc1 = lists:foldl(fun(KeyArgs, KeyAcc0) ->
+ Opts = mrargs_to_fdb_options(KeyArgs),
+ KeyAcc1 = KeyAcc0#{
+ mrargs := KeyArgs
+ },
+ couch_views_fdb:fold_map_idx(
+ TxDb,
+ Sig,
+ ViewId,
+ Opts,
+ Fun,
+ KeyAcc1
+ )
+ end, Acc0, expand_keys_args(Args)),
#{
acc := UserAcc2
@@ -108,6 +113,18 @@ get_view_id(Lang, Args, ViewName, Views) ->
end.
+expand_keys_args(#mrargs{keys = undefined} = Args) ->
+ [Args];
+
+expand_keys_args(#mrargs{keys = Keys} = Args) ->
+ lists:map(fun(Key) ->
+ Args#mrargs{
+ start_key = Key,
+ end_key = Key
+ }
+ end, Keys).
+
+
mrargs_to_fdb_options(Args) ->
#mrargs{
start_key = StartKey0,