You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/07/29 07:37:57 UTC

[GitHub] [couchdb] garrensmith opened a new pull request #3043: add local_seq option to views

garrensmith opened a new pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043


   <!-- Thank you for your contribution!
   
        Please file this form by replacing the Markdown comments
        with your text. If a section needs no action - remove it.
   
        Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
        of code collaboration. Positive feedback is represented +1 from committers
        and negative is a -1. The -1 also means veto, and needs to be addressed
        to proceed. Once there are no objections, the PR can be merged by a
        CouchDB committer.
   
        See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
   
   ## Overview
   
   Add support for the `_local_seq` option to views https://docs.couchdb.org/en/stable/api/ddoc/views.html#view-options
   
   ## Testing recommendations
   
   `make check` should pass
   
   ## Related Issues or Pull Requests
   
   <!-- If your changes affects multiple components in different
        repositories please put links to those issues or pull requests here.  -->
   
   ## Checklist
   
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [ ] A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] tonysun83 commented on pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
tonysun83 commented on pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#issuecomment-665192290






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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] tonysun83 removed a comment on pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
tonysun83 removed a comment on pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#issuecomment-665196787


   +1


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] garrensmith commented on a change in pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
garrensmith commented on a change in pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#discussion_r462127734



##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -407,17 +408,26 @@ fetch_docs(Db, Changes) ->
         }
     end, #{}, erlfdb:wait_for_all(RevFutures)),
 
+    AddLocalSeq = lists:keymember(<<"local_seq">>, 1, DesignOpts),

Review comment:
       @nickva good spot. I've changed it to use `get_value`




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] garrensmith merged pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
garrensmith merged pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] nickva commented on pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
nickva commented on pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#issuecomment-665220158


   @garrensmith This is a nice feature!
   
   See a minor comment about keymember vs keyfind and value checking.
   
   Then perhaps we could add is a eunit test to maintain test coverage in fabric. There is already a map test with a variety of views in https://github.com/apache/couchdb/blob/12b7cdc4355866113c1df3f7ba2b036cbdd6c8a0/src/couch_views/test/couch_views_map_test.erl#L499 so could add it there. Maybe one where it is defined and `false` and the other one where it is `true`.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] tonysun83 commented on a change in pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
tonysun83 commented on a change in pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#discussion_r461688953



##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -407,17 +408,27 @@ fetch_docs(Db, Changes) ->
         }
     end, #{}, erlfdb:wait_for_all(RevFutures)),
 
+    AddLocalSeq = lists:keymember(<<"local_seq">>, 1, DesignOpts),
     BodyFutures = maps:keys(BodyState),
     ChangesWithDocs = lists:map(fun (BodyFuture) ->
         {Id, RevInfo, Change} = maps:get(BodyFuture, BodyState),
         Doc = fabric2_fdb:get_doc_body_wait(Db, Id, RevInfo, BodyFuture),
 
         BranchCount = maps:get(branch_count, RevInfo, 1),
-        Doc1 = if BranchCount == 1 -> Doc; true ->
-            RevConflicts = fabric2_fdb:get_all_revs(Db, Id),
-            {ok, DocWithConflicts} = fabric2_db:apply_open_doc_opts(Doc,
-                RevConflicts, [conflicts]),
-            DocWithConflicts
+        Doc1 = case BranchCount == 1 of

Review comment:
       I didn't see BranchCount used else, so perhaps it could just be removed and instead the clause can be 👍 
   ```
   case maps:get(branch_count, RevInfo, 1) of
      1  when AddLocalSeq -> ->
          ....
       1 ->
          ....
       _ ->
          ..... 
   end,
   ```

##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -407,17 +408,27 @@ fetch_docs(Db, Changes) ->
         }
     end, #{}, erlfdb:wait_for_all(RevFutures)),
 
+    AddLocalSeq = lists:keymember(<<"local_seq">>, 1, DesignOpts),
     BodyFutures = maps:keys(BodyState),
     ChangesWithDocs = lists:map(fun (BodyFuture) ->
         {Id, RevInfo, Change} = maps:get(BodyFuture, BodyState),
         Doc = fabric2_fdb:get_doc_body_wait(Db, Id, RevInfo, BodyFuture),
 
         BranchCount = maps:get(branch_count, RevInfo, 1),
-        Doc1 = if BranchCount == 1 -> Doc; true ->
-            RevConflicts = fabric2_fdb:get_all_revs(Db, Id),
-            {ok, DocWithConflicts} = fabric2_db:apply_open_doc_opts(Doc,
-                RevConflicts, [conflicts]),
-            DocWithConflicts
+        Doc1 = case BranchCount == 1 of

Review comment:
       I didn't see BranchCount used else, so perhaps it could just be removed and instead the clause can be: 
   ```
   case maps:get(branch_count, RevInfo, 1) of
      1  when AddLocalSeq -> ->
          ....
      1 ->
          ....
       _ ->
          ..... 
   end,
   ```

##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -407,17 +408,27 @@ fetch_docs(Db, Changes) ->
         }
     end, #{}, erlfdb:wait_for_all(RevFutures)),
 
+    AddLocalSeq = lists:keymember(<<"local_seq">>, 1, DesignOpts),
     BodyFutures = maps:keys(BodyState),
     ChangesWithDocs = lists:map(fun (BodyFuture) ->
         {Id, RevInfo, Change} = maps:get(BodyFuture, BodyState),
         Doc = fabric2_fdb:get_doc_body_wait(Db, Id, RevInfo, BodyFuture),
 
         BranchCount = maps:get(branch_count, RevInfo, 1),
-        Doc1 = if BranchCount == 1 -> Doc; true ->
-            RevConflicts = fabric2_fdb:get_all_revs(Db, Id),
-            {ok, DocWithConflicts} = fabric2_db:apply_open_doc_opts(Doc,
-                RevConflicts, [conflicts]),
-            DocWithConflicts
+        Doc1 = case BranchCount == 1 of

Review comment:
       I didn't see BranchCount used elsewhere, so perhaps it could just be removed and instead the clause can be: 
   ```
   case maps:get(branch_count, RevInfo, 1) of
      1  when AddLocalSeq -> ->
          ....
      1 ->
          ....
       _ ->
          ..... 
   end,
   ```

##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -379,7 +380,7 @@ write_docs(TxDb, Mrst, Docs, State) ->
     DocsNumber.
 
 
-fetch_docs(Db, Changes) ->
+fetch_docs(Db, DesignOpts ,Changes) ->

Review comment:
       oh whitespace here

##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -379,7 +380,7 @@ write_docs(TxDb, Mrst, Docs, State) ->
     DocsNumber.
 
 
-fetch_docs(Db, Changes) ->
+fetch_docs(Db, DesignOpts ,Changes) ->

Review comment:
       DesignOpts, 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] nickva commented on a change in pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
nickva commented on a change in pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#discussion_r461784853



##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -407,17 +408,26 @@ fetch_docs(Db, Changes) ->
         }
     end, #{}, erlfdb:wait_for_all(RevFutures)),
 
+    AddLocalSeq = lists:keymember(<<"local_seq">>, 1, DesignOpts),

Review comment:
       `keymember` will indicate that the option is present only? Maybe we want a keyfind here http://erlang.org/doc/man/lists.html#keyfind-3 then if tuple is present check the value? 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] garrensmith commented on pull request #3043: add local_seq option to views

Posted by GitBox <gi...@apache.org>.
garrensmith commented on pull request #3043:
URL: https://github.com/apache/couchdb/pull/3043#issuecomment-665195781


   thanks @tonysun83 I've made the fix.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org