summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2023-04-02 16:50:50 +0100
committerRobert Newson <rnewson@apache.org>2023-04-02 16:54:44 +0100
commit23dc895b1353d85bed1432cb344167beff83f5c7 (patch)
tree56ceb36e7b54b7c78bbec740d8e42722e2fe301e
parent11e33944b9249aad50ea60104bc6b8859d758838 (diff)
downloadcouchdb-23dc895b1353d85bed1432cb344167beff83f5c7.tar.gz
encapsulate lucene majors
-rw-r--r--src/nouveau/include/nouveau.hrl4
-rw-r--r--src/nouveau/src/nouveau_index_manager.erl9
-rw-r--r--src/nouveau/src/nouveau_rpc.erl8
-rw-r--r--src/nouveau/src/nouveau_util.erl4
4 files changed, 19 insertions, 6 deletions
diff --git a/src/nouveau/include/nouveau.hrl b/src/nouveau/include/nouveau.hrl
index 177546832..e15e11a57 100644
--- a/src/nouveau/include/nouveau.hrl
+++ b/src/nouveau/include/nouveau.hrl
@@ -22,3 +22,7 @@
name,
sig=nil
}).
+
+-define(DEFAULT_LUCENE_MAJOR, 9).
+
+-define(LUCENE_MAJORS, [4, 9]). \ No newline at end of file
diff --git a/src/nouveau/src/nouveau_index_manager.erl b/src/nouveau/src/nouveau_index_manager.erl
index 5e178c12d..a4080c1fd 100644
--- a/src/nouveau/src/nouveau_index_manager.erl
+++ b/src/nouveau/src/nouveau_index_manager.erl
@@ -127,9 +127,12 @@ handle_info(_Msg, State) ->
handle_db_event(DbName, deleted, State) ->
couch_log:notice("Deleting indexes for ~s as database was deleted", [DbName]),
- %% ugly to have to know all the lucene majors here.
- nouveau_api:delete_path(4, nouveau_util:index_name(DbName)),
- nouveau_api:delete_path(9, nouveau_util:index_name(DbName)),
+ lists:foreach(
+ fun(Major) ->
+ nouveau_api:delete_path(Major, nouveau_util:index_name(DbName))
+ end,
+ ?LUCENE_MAJORS
+ ),
{ok, State};
handle_db_event(_DbName, _Event, State) ->
{ok, State}.
diff --git a/src/nouveau/src/nouveau_rpc.erl b/src/nouveau/src/nouveau_rpc.erl
index 9612628c6..ead112d98 100644
--- a/src/nouveau/src/nouveau_rpc.erl
+++ b/src/nouveau/src/nouveau_rpc.erl
@@ -53,6 +53,10 @@ info(DbName, #index{} = Index0) ->
rexi:reply(nouveau_api:index_info(Index1)).
cleanup(DbName, Exclusions) ->
- nouveau_api:delete_path(4, nouveau_util:index_name(DbName), Exclusions),
- nouveau_api:delete_path(9, nouveau_util:index_name(DbName), Exclusions),
+ lists:foreach(
+ fun(Major) ->
+ nouveau_api:delete_path(Major, nouveau_util:index_name(DbName), Exclusions)
+ end,
+ ?LUCENE_MAJORS
+ ),
rexi:reply(ok).
diff --git a/src/nouveau/src/nouveau_util.erl b/src/nouveau/src/nouveau_util.erl
index a2861d229..7c351b392 100644
--- a/src/nouveau/src/nouveau_util.erl
+++ b/src/nouveau/src/nouveau_util.erl
@@ -62,7 +62,9 @@ design_doc_to_index(DbName, #doc{id = Id, body = {Fields}}, IndexName) ->
false ->
{error, {not_found, <<IndexName/binary, " not found.">>}};
{IndexName, {Index}} ->
- DefaultLuceneMajor = config:get_integer("nouveau", "default_lucene_major", 9),
+ DefaultLuceneMajor = config:get_integer(
+ "nouveau", "default_lucene_major", ?DEFAULT_LUCENE_MAJOR
+ ),
LuceneMajor = couch_util:get_value(
<<"lucene_major">>, Index, DefaultLuceneMajor
),