You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/02/05 22:13:18 UTC

[couchdb] branch fdb-mango-indexes updated: Simplify modify_int

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch fdb-mango-indexes
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/fdb-mango-indexes by this push:
     new b4a45ca  Simplify modify_int
b4a45ca is described below

commit b4a45ca1f809db8eca2874160ecf6a192215beb5
Author: Jay Doane <ja...@apache.org>
AuthorDate: Wed Feb 5 13:27:00 2020 -0800

    Simplify modify_int
    
    Previously, a doc body loading bug in `mango_idx:list` prevented this
    simplification from working.
---
 src/mango/src/mango_indexer.erl | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/mango/src/mango_indexer.erl b/src/mango/src/mango_indexer.erl
index c7632a7..0f163ff 100644
--- a/src/mango/src/mango_indexer.erl
+++ b/src/mango/src/mango_indexer.erl
@@ -42,7 +42,7 @@ delete_doc(Db, PrevDoc) ->
 
 modify(Db, Change, Doc, PrevDoc) ->
     try
-        modify_int(Db, Change, Doc, PrevDoc)
+        modify_int(Db, Change, Doc, PrevDoc, json_indexes(Db))
     catch
         Error:Reason ->
             io:format("ERROR INDEXER ~p ~p ~p ~n", [Error, Reason, erlang:display(erlang:get_stacktrace())]),
@@ -70,7 +70,7 @@ doc_id(#doc{id = DocId}, _) ->
 % Todo: Check if design doc is mango index and kick off background worker
 % to build new index
 modify_int(Db, _Change, #doc{id = <<?DESIGN_DOC_PREFIX, _/binary>>} = Doc,
-        _PrevDoc) ->
+        _PrevDoc, _Indexes) ->
     {Props} = JSONDoc = couch_doc:to_json_obj(Doc, []),
     case proplists:get_value(<<"language">>, Props) of
         <<"query">> ->
@@ -80,16 +80,15 @@ modify_int(Db, _Change, #doc{id = <<?DESIGN_DOC_PREFIX, _/binary>>} = Doc,
             ok
     end;
 
-modify_int(Db, delete, _, PrevDoc)  ->
-    remove_doc(Db, PrevDoc, json_indexes(Db));
+modify_int(Db, delete, _, PrevDoc, Indexes)  ->
+    remove_doc(Db, PrevDoc, Indexes);
 
-modify_int(Db, update, Doc, PrevDoc) ->
-    Indexes = json_indexes(Db),
+modify_int(Db, update, Doc, PrevDoc, Indexes) ->
     remove_doc(Db, PrevDoc, Indexes),
     write_doc(Db, Doc, Indexes);
 
-modify_int(Db, create, Doc, _) ->
-    write_doc(Db, Doc, json_indexes(Db)).
+modify_int(Db, create, Doc, _, Indexes) ->
+    write_doc(Db, Doc, Indexes).
 
 
 remove_doc(Db, #doc{} = Doc, Indexes) ->