jiahuili430 commented on code in PR #4862:
URL: https://github.com/apache/couchdb/pull/4862#discussion_r1414514722


##########
src/fabric/src/fabric_rpc.erl:
##########
@@ -535,6 +535,32 @@ changes_enumerator(#full_doc_info{} = FDI, Acc) ->
 changes_enumerator(#doc_info{id = <<"_local/", _/binary>>, high_seq = Seq}, 
Acc) ->
     {ok, Acc#fabric_changes_acc{seq = Seq, pending = 
Acc#fabric_changes_acc.pending - 1}};
 changes_enumerator(DocInfo, Acc) ->
+    #fabric_changes_acc{
+        db = Db,
+        args = #changes_args{
+            include_docs = IncludeDocs,
+            filter_fun = Filter
+        },
+        pending = Pending
+    } = Acc,
+    #doc_info{high_seq = Seq} = DocInfo,
+    RevsOrDocRevs = couch_changes:filter(Db, DocInfo, Filter, IncludeDocs),
+    % include_docs = false, call `filter/3`, use `couch_changes:open_revs/3` 
to read docs.
+    % include_docs = true, call `filter/4`, it will return [revs] or {docs, 
revs}.
+    %  - {}: use `couch_changes:open_revs/3` to open docs
+    %  - []: use `fabric_rpc:doc_member/3` to open docs
+    ChangesRow =
+        case is_tuple(RevsOrDocRevs) of
+            true ->
+                {Docs, Revs} = RevsOrDocRevs,
+                get_changes_row(Revs, Acc, DocInfo, fun get_json_docs/3, Docs);
+            false ->
+                get_changes_row(RevsOrDocRevs, Acc, DocInfo, fun doc_member/3, 
{Db, DocInfo})
+        end,

Review Comment:
   Thank you for the review!
   
   I have updated PR as follows:
   - `filter/4` will always return `{Docs, Revs}`;
   - `ChangesRow` is based on the case statement:
   ```erlang
   case {Changes, Docs, IncludeDocs} of
     {[], _, _} -> {no_pass, ...};
     {_, _, false} -> ...;
     {_, [], true} -> ...; % open docs in `doc_member/4`
     {_, [Doc], true} -> ... % docs were opened in `couch_changes:open_revs/3`, 
call `get_json_doc/3` to convert docs to json object
   end
   ```
   



-- 
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]

Reply via email to