summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangph <jiangph@cn.ibm.com>2020-03-23 20:03:43 +0800
committerjiangph <jiangph@cn.ibm.com>2020-03-24 14:10:31 +0800
commit2c704acc78c4f9f7cf8bb40420be5b8c915d39b9 (patch)
treea7270b28c8d68a9adf1d05e586984be2ad7429d6
parentf81f117033422c463d6230569973c9c70a1d2565 (diff)
downloadcouchdb-2c704acc78c4f9f7cf8bb40420be5b8c915d39b9.tar.gz
set DbPrefix with value allocated with erlfdb_hca
Previously we are using the DbName to set DbPrefix for clarity. In order to support soft-deletion while providing efficient value for DbPrefix allocation, we use value allocated with erlfdb_hca for DbPrefix.
-rw-r--r--src/fabric/include/fabric2.hrl1
-rw-r--r--src/fabric/src/fabric2_fdb.erl6
2 files changed, 4 insertions, 3 deletions
diff --git a/src/fabric/include/fabric2.hrl b/src/fabric/include/fabric2.hrl
index a4f68bdf6..0c0757567 100644
--- a/src/fabric/include/fabric2.hrl
+++ b/src/fabric/include/fabric2.hrl
@@ -21,6 +21,7 @@
-define(CLUSTER_CONFIG, 0).
-define(ALL_DBS, 1).
+-define(DB_HCA, 2).
-define(DBS, 15).
-define(TX_IDS, 255).
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index f5f7bec83..14a649d50 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -177,10 +177,10 @@ 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),
+ HCA = erlfdb_hca:create(erlfdb_tuple:pack({?DB_HCA}, LayerPrefix)),
+ AllocPrefix = erlfdb_hca:allocate(HCA, Tx),
+ DbPrefix = erlfdb_tuple:pack({?DBS, AllocPrefix}, LayerPrefix),
erlfdb:set(Tx, DbKey, DbPrefix),
% This key is responsible for telling us when something in