You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/10/14 20:32:44 UTC
[couchdb] branch prototype/fdb-layer-dry-out-couchdb-prefix-opening
created (now ba0799c)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch prototype/fdb-layer-dry-out-couchdb-prefix-opening
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at ba0799c DRY out CouchDB FDB prefix fetching
This branch includes the following new commits:
new ba0799c DRY out CouchDB FDB prefix fetching
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: DRY out CouchDB FDB prefix fetching
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch prototype/fdb-layer-dry-out-couchdb-prefix-opening
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ba0799cc4b8b09dd5e931a57b3bac672bf14a666
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Oct 14 16:30:22 2019 -0400
DRY out CouchDB FDB prefix fetching
It was suggested in another PR's discussion:
https://github.com/apache/couchdb/pull/2107#pullrequestreview-274431487
---
src/couch_jobs/src/couch_jobs_fdb.erl | 5 +----
src/fabric/src/fabric2_fdb.erl | 15 +++++++++------
src/fabric/src/fabric2_txids.erl | 10 ++--------
3 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/src/couch_jobs/src/couch_jobs_fdb.erl b/src/couch_jobs/src/couch_jobs_fdb.erl
index 6903801..00a8ddf 100644
--- a/src/couch_jobs/src/couch_jobs_fdb.erl
+++ b/src/couch_jobs/src/couch_jobs_fdb.erl
@@ -615,10 +615,7 @@ init_jtx(undefined) ->
fabric2_fdb:transactional(fun(Tx) -> init_jtx(Tx) end);
init_jtx({erlfdb_transaction, _} = Tx) ->
- Root = erlfdb_directory:root(),
- Dir = fabric2_server:fdb_directory(),
- CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
- LayerPrefix = erlfdb_directory:get_name(CouchDB),
+ LayerPrefix = fabric2_fdb:create_or_open_couchdb_dir(Tx),
Jobs = erlfdb_tuple:pack({?JOBS}, LayerPrefix),
Version = erlfdb:wait(erlfdb:get(Tx, ?METADATA_VERSION_KEY)),
% layer_prefix, md_version and tx here match db map fields in fabric2_fdb
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 5c58da4..5471f99 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -24,6 +24,8 @@
delete/1,
exists/1,
+ create_or_open_couchdb_dir/1,
+
list_dbs/4,
get_info/1,
@@ -274,11 +276,15 @@ exists(#{name := DbName} = Db) when is_binary(DbName) ->
end.
-list_dbs(Tx, Callback, AccIn, Options) ->
+create_or_open_couchdb_dir(Tx) ->
Root = erlfdb_directory:root(),
Dir = fabric2_server:fdb_directory(),
CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
- LayerPrefix = erlfdb_directory:get_name(CouchDB),
+ erlfdb_directory:get_name(CouchDB).
+
+
+list_dbs(Tx, Callback, AccIn, Options) ->
+ LayerPrefix = create_or_open_couchdb_dir(Tx),
Prefix = erlfdb_tuple:pack({?ALL_DBS}, LayerPrefix),
fold_range({tx, Tx}, Prefix, fun({K, _V}, Acc) ->
{DbName} = erlfdb_tuple:unpack(K, Prefix),
@@ -781,10 +787,7 @@ debug_cluster(Start, End) ->
init_db(Tx, DbName, Options) ->
- Root = erlfdb_directory:root(),
- Dir = fabric2_server:fdb_directory(),
- CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
- Prefix = erlfdb_directory:get_name(CouchDB),
+ Prefix = create_or_open_couchdb_dir(Tx),
Version = erlfdb:wait(erlfdb:get(Tx, ?METADATA_VERSION_KEY)),
#{
name => DbName,
diff --git a/src/fabric/src/fabric2_txids.erl b/src/fabric/src/fabric2_txids.erl
index 06704f0..f1a7524 100644
--- a/src/fabric/src/fabric2_txids.erl
+++ b/src/fabric/src/fabric2_txids.erl
@@ -44,10 +44,7 @@ start_link() ->
create(Tx, undefined) ->
- Root = erlfdb_directory:root(),
- Dir = fabric2_server:fdb_directory(),
- CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
- Prefix = erlfdb_directory:get_name(CouchDB),
+ Prefix = fabric2_fdb:create_or_open_couchdb_dir(Tx),
create(Tx, Prefix);
create(_Tx, LayerPrefix) ->
@@ -136,10 +133,7 @@ clean(St, NeedsSweep) ->
sweep(Tx, {Mega, Secs, Micro}) ->
- Root = erlfdb_directory:root(),
- Dir = fabric2_server:fdb_directory(),
- CouchDB = erlfdb_directory:create_or_open(Tx, Root, Dir),
- Prefix = erlfdb_directory:get_name(CouchDB),
+ Prefix = fabric2_fdb:create_or_open_couchdb_dir(Tx),
StartKey = erlfdb_tuple:pack({?TX_IDS}, Prefix),
EndKey = erlfdb_tuple:pack({?TX_IDS, Mega, Secs, Micro}, Prefix),
erlfdb:set_option(Tx, next_write_no_write_conflict_range),