jaydoane commented on a change in pull request #3969:
URL: https://github.com/apache/couchdb/pull/3969#discussion_r836699238
##########
File path: src/fabric/src/fabric_view.erl
##########
@@ -155,6 +157,12 @@ maybe_send_row(State) ->
{ok, State};
false ->
try get_next_row(State) of
+ {_, NewState} when SkipDesign andalso Skip > 0 ->
+ [#view_row{key = Key}] = Rows,
Review comment:
Doesn't this only match exactly one row?
##########
File path: src/chttpd/test/eunit/chttpd_dbs_info_test.erl
##########
@@ -263,6 +303,24 @@ mock_db_not_exist() ->
fun(_) -> {error, database_does_not_exist} end
).
+create_shards_db_ddoc(Suffix) ->
+ DDocId = ?l2b("_design/ddoc-" ++ Suffix),
+ DDoc = #{<<"_id">> => DDocId},
+ ShardsDb = "_node/_local/" ++ config:get("mem3", "shards_db", "_dbs"),
Review comment:
You can use `mem3_sync:shards_db/0` here instead.
##########
File path: src/fabric/src/fabric_view.erl
##########
@@ -155,6 +157,12 @@ maybe_send_row(State) ->
{ok, State};
false ->
try get_next_row(State) of
+ {_, NewState} when SkipDesign andalso Skip > 0 ->
+ [#view_row{key = Key}] = Rows,
+ case Key of
+ <<"_design", _/binary>> -> maybe_send_row(NewState);
+ _ -> maybe_send_row(NewState#collector{skip = Skip -
1})
+ end;
Review comment:
Is this easier to read?
```erlang
NewSkip =
case Key of
<<"_design", _/binary>> -> Skip;
_ -> Skip - 1
end,
maybe_send_row(NewState#collector{skip = NewSkip});
```
##########
File path: src/fabric/src/fabric_view.erl
##########
@@ -469,8 +479,11 @@ fix_skip_and_limit(#mrargs{} = Args) ->
{CoordArgs, WorkerArgs} =
case couch_mrview_util:get_extra(Args, partition) of
undefined ->
- #mrargs{skip = Skip, limit = Limit} = Args,
- {Args, Args#mrargs{skip = 0, limit = Skip + Limit}};
+ #mrargs{skip = Skip, limit = Limit, max_view = Max} = Args,
+ case Args#mrargs.skip_design of
+ true -> {Args, Args#mrargs{skip = 0, limit = Skip + Max}};
+ false -> {Args, Args#mrargs{skip = 0, limit = Skip +
Limit}}
+ end;
Review comment:
I wonder if something like this would be easier to read?
```erlang
NewLimit =
Skip + case Args#mrargs.skip_design of
true -> Max;
false -> Limit
end,
{Args, Args#mrargs{skip = 0, limit = NewLimit}};
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]