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 2019/10/23 20:12:59 UTC

[GitHub] [couchdb] nickva commented on a change in pull request #2267: Chunkify local docs

nickva commented on a change in pull request #2267: Chunkify local docs
URL: https://github.com/apache/couchdb/pull/2267#discussion_r338254995
 
 

 ##########
 File path: src/fabric/src/fabric2_fdb.erl
 ##########
 @@ -647,19 +652,29 @@ write_doc(#{} = Db0, Doc, NewWinner0, OldWinner, ToUpdate, ToRemove) ->
 
 write_local_doc(#{} = Db0, Doc) ->
     #{
-        tx := Tx
+        tx := Tx,
+        db_prefix := DbPrefix
     } = Db = ensure_current(Db0),
 
-    {LDocKey, LDocVal} = local_doc_to_fdb(Db, Doc),
+    Id = Doc#doc.id,
+
+    {LDocKey, LDocVal, Rows} = local_doc_to_fdb(Db, Doc),
+
+    upgrade_local_doc(Db, Id),
 
     WasDeleted = case erlfdb:wait(erlfdb:get(Tx, LDocKey)) of
         <<_/binary>> -> false;
         not_found -> true
     end,
 
     case Doc#doc.deleted of
-        true -> erlfdb:clear(Tx, LDocKey);
-        false -> erlfdb:set(Tx, LDocKey, LDocVal)
+        true ->
+            erlfdb:clear(Tx, LDocKey),
+            Prefix = erlfdb_tuple:pack({?DB_LOCAL_DOC_BODIES, Id}, DbPrefix),
+            erlfdb:clear_range_startswith(Tx, Prefix);
+        false ->
+            erlfdb:set(Tx, LDocKey, LDocVal),
+            lists:foreach(fun({K, V}) -> erlfdb:set(Tx, K, V) end, Rows)
 
 Review comment:
   Ooh. Good catch. And good idea to add a test for it

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


With regards,
Apache Git Services