Skip to content

Commit

Permalink
[fixup] Implement review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pgj committed Mar 14, 2024
1 parent 5820d27 commit 1046c4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
22 changes: 13 additions & 9 deletions src/fabric/src/fabric_view_row.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@
% the License.

-module(fabric_view_row).
-export([from_props/2]).
-export([get_id/1, get_key/1, get_value/1, get_doc/1, get_worker/1]).
-export([set_key/2, set_doc/2, set_worker/2]).
-export([transform/1]).
-export([
from_props/2,
get_id/1,
get_key/1,
get_value/1,
get_doc/1,
get_worker/1,
set_key/2,
set_doc/2,
set_worker/2,
transform/1
]).

-include_lib("fabric/include/fabric.hrl").

from_props(Props, Options) ->
case couch_util:get_value(view_row_map, Options, false) of
true ->
Row = lists:foldl(
fun({Key, Value}, ViewRow) -> ViewRow#{Key => Value} end,
#{},
Props
),
Row = maps:from_list(Props),
{view_row, Row};
false ->
#view_row{
Expand Down
12 changes: 6 additions & 6 deletions src/mango/src/mango_cursor_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ view_cb({meta, Meta}, Acc) ->
view_cb({row, Props}, #mrargs{extra = Options} = Acc) ->
mango_execution_stats:shard_incr_keys_examined(),
couch_stats:increment_counter([mango, keys_examined]),
ViewRow0 = fabric_view_row:from_props(Props, Options),
ViewRow = fabric_view_row:from_props(Props, Options),
% This supports receiving our "arguments" either as just the `selector`
% or in the new record in `callback_args`. This is to support mid-upgrade
% clusters where the non-upgraded coordinator nodes will send the older style.
Expand All @@ -381,23 +381,23 @@ view_cb({row, Props}, #mrargs{extra = Options} = Acc) ->
% However, this oddness is confined to being visible in this module.
case match_and_extract_doc(Doc, Selector, Fields) of
{match, FinalDoc} ->
ViewRow = fabric_view_row:set_doc(ViewRow0, FinalDoc),
ok = rexi:stream2(ViewRow),
ViewRow1 = fabric_view_row:set_doc(ViewRow, FinalDoc),
ok = rexi:stream2(ViewRow1),
set_mango_msg_timestamp();
{no_match, undefined} ->
maybe_send_mango_ping()
end
end,
ViewRowDoc = fabric_view_row:get_doc(ViewRow0),
ViewRowDoc = fabric_view_row:get_doc(ViewRow),
case {ViewRowDoc, CoveringIndex} of
{null, _} ->
maybe_send_mango_ping();
{undefined, Index = #idx{}} ->
Doc = derive_doc_from_index(Index, ViewRow0),
Doc = derive_doc_from_index(Index, ViewRow),
Process(Doc);
{undefined, _} ->
% include_docs=false. Use quorum fetch at coordinator
ok = rexi:stream2(ViewRow0),
ok = rexi:stream2(ViewRow),
set_mango_msg_timestamp();
{Doc, _} ->
mango_execution_stats:shard_incr_docs_examined(),
Expand Down

0 comments on commit 1046c4b

Please sign in to comment.