diff options
author | jiangph <jiangph@cn.ibm.com> | 2020-03-23 20:03:43 +0800 |
---|---|---|
committer | jiangph <jiangph@cn.ibm.com> | 2020-03-23 20:05:57 +0800 |
commit | 23487807dea165e878e78c0435acd946ce6293a7 (patch) | |
tree | edc4230c89d2d973eac48db75c265c62c4ae749b | |
parent | 3fba9ff5bea733b4c722d2bb4f924afe416f6e35 (diff) | |
download | couchdb-23487807dea165e878e78c0435acd946ce6293a7.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.hrl | 2 | ||||
-rw-r--r-- | src/fabric/src/fabric2_fdb.erl | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/fabric/include/fabric2.hrl b/src/fabric/include/fabric2.hrl index a4f68bdf6..2d7711fdb 100644 --- a/src/fabric/include/fabric2.hrl +++ b/src/fabric/include/fabric2.hrl @@ -17,6 +17,8 @@ % Prefix Definitions +-define(DEFAULT_DB_PREFIX, <<16#FD>>). + % Layer Level: (LayerPrefix, X, ...) -define(CLUSTER_CONFIG, 0). diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl index f5f7bec83..632694927 100644 --- a/src/fabric/src/fabric2_fdb.erl +++ b/src/fabric/src/fabric2_fdb.erl @@ -177,10 +177,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), erlfdb:set(Tx, DbKey, DbPrefix), % This key is responsible for telling us when something in |