davisp commented on a change in pull request #2666: [WIP] soft-deletion for 
database
URL: https://github.com/apache/couchdb/pull/2666#discussion_r396594839
 
 

 ##########
 File path: src/fabric/src/fabric2_fdb.erl
 ##########
 @@ -177,10 +181,13 @@ create(#{} = Db0, Options) ->
         layer_prefix := LayerPrefix
     } = Db = ensure_current(Db0, false),
 
-    % Eventually DbPrefix will be HCA allocated. For now
-    % we're just using the DbName so that debugging is easier.
     DbKey = erlfdb_tuple:pack({?ALL_DBS, DbName}, LayerPrefix),
-    DbPrefix = erlfdb_tuple:pack({?DBS, DbName}, LayerPrefix),
+    DefDbPref = ?DEFAULT_DB_PREFIX,
+    AllDbPrefix = erlfdb_util:get(Options, db_prefix, DefDbPref),
+    DbId = erlfdb_tuple:pack({AllDbPrefix}, AllDbPrefix),
+    DbPrefixAllocator = erlfdb_hca:create(erlfdb_tuple:pack({DbId}, 
<<"hca">>)),
+    AllocPrefix = erlfdb_hca:allocate(DbPrefixAllocator, Tx),
+    DbPrefix = erlfdb_tuple:pack({?DBS, AllocPrefix}, LayerPrefix),
 
 Review comment:
   There's a lot of unnecessary going on here. You should just need something 
like:
   
   ```erlang
   HCAKey = erlfdb_tuple:pack({?DB_HCA}, LayerPrefix),
   HCA = erlfdb_hca:create(HCAKey),
   DbPrefix = erlfdb_hca:allocate(HCA).
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to