You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2025/08/22 20:40:42 UTC
(couchdb) branch nouveau-improvements created (now efb24a3a3)
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a change to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at efb24a3a3 gun takes iodata so no need for io_lib or flatten
This branch includes the following new commits:
new 4cc9c2b4c Use copy_props in the compactor instead of set_props
new 9bb937448 Minor couch_btree refactoring
new 8638c8735 retry if no connection available
new 7199abd3d switch to couch_util:to_hex_bin
new efb24a3a3 gun takes iodata so no need for io_lib or flatten
The 5 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) 03/05: retry if no connection available
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 8638c8735772230528cfba1fa711dc5809f72a30
Author: Robert Newson <rn...@apache.org>
AuthorDate: Thu Aug 7 12:14:02 2025 +0100
retry if no connection available
---
src/nouveau/src/nouveau_api.erl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/nouveau/src/nouveau_api.erl b/src/nouveau/src/nouveau_api.erl
index 73aff2c1f..64f5a948a 100644
--- a/src/nouveau/src/nouveau_api.erl
+++ b/src/nouveau/src/nouveau_api.erl
@@ -281,6 +281,9 @@ send_if_enabled(Path, ReqHeaders, Method) ->
send_if_enabled(Path, ReqHeaders, Method, <<>>).
send_if_enabled(Path, ReqHeaders, Method, ReqBody) ->
+ send_if_enabled(Path, ReqHeaders, Method, ReqBody, 5).
+
+send_if_enabled(Path, ReqHeaders, Method, ReqBody, RemainingTries) ->
case nouveau:enabled() of
true ->
case
@@ -306,6 +309,9 @@ send_if_enabled(Path, ReqHeaders, Method, ReqBody) ->
{error, Reason} ->
{error, Reason}
end;
+ {error, no_connection_available, _Reason} when RemainingTries > 0 ->
+ timer:sleep(1000),
+ send_if_enabled(Path, ReqHeaders, Method, ReqBody, RemainingTries - 1);
{error, _Type, Reason} ->
{error, Reason}
end;
(couchdb) 04/05: switch to couch_util:to_hex_bin
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7199abd3de089999ab0e59218b508758f588d945
Author: Robert Newson <rn...@apache.org>
AuthorDate: Fri Aug 8 10:40:47 2025 +0100
switch to couch_util:to_hex_bin
---
src/nouveau/src/nouveau_util.erl | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/nouveau/src/nouveau_util.erl b/src/nouveau/src/nouveau_util.erl
index ad0ce6663..0dfcb1e1e 100644
--- a/src/nouveau/src/nouveau_util.erl
+++ b/src/nouveau/src/nouveau_util.erl
@@ -73,16 +73,15 @@ design_doc_to_index(DbName, #doc{id = Id, body = {Fields}}, IndexName) ->
undefined ->
{error, InvalidDDocError};
Def ->
- Sig = ?l2b(
- couch_util:to_hex(
+ Sig =
+ couch_util:to_hex_bin(
crypto:hash(
sha256,
?term_to_bin(
{DefaultAnalyzer, FieldAnalyzers, Def}
)
)
- )
- ),
+ ),
{ok, #index{
dbname = DbName,
default_analyzer = DefaultAnalyzer,
(couchdb) 05/05: gun takes iodata so no need for io_lib or flatten
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit efb24a3a3f9713bbde31647907b716c4721095f8
Author: Robert Newson <rn...@apache.org>
AuthorDate: Fri Aug 8 16:24:58 2025 +0100
gun takes iodata so no need for io_lib or flatten
---
src/nouveau/src/nouveau_api.erl | 37 ++++++++++---------------------------
1 file changed, 10 insertions(+), 27 deletions(-)
diff --git a/src/nouveau/src/nouveau_api.erl b/src/nouveau/src/nouveau_api.erl
index 64f5a948a..319170a4c 100644
--- a/src/nouveau/src/nouveau_api.erl
+++ b/src/nouveau/src/nouveau_api.erl
@@ -217,37 +217,20 @@ set_seq(#index{} = Index, ReqBody) ->
%% private functions
index_path(Path) when is_binary(Path) ->
- lists:flatten(
- io_lib:format(
- "/index/~s",
- [
- couch_util:url_encode(Path)
- ]
- )
- );
+ [<<"/index/">>, couch_util:url_encode(Path)];
index_path(#index{} = Index) ->
- lists:flatten(
- io_lib:format(
- "/index/~s",
- [
- couch_util:url_encode(nouveau_util:index_name(Index))
- ]
- )
- ).
+ [<<"/index/">>, couch_util:url_encode(nouveau_util:index_name(Index))].
doc_path(#index{} = Index, DocId) ->
- lists:flatten(
- io_lib:format(
- "/index/~s/doc/~s",
- [
- couch_util:url_encode(nouveau_util:index_name(Index)),
- couch_util:url_encode(DocId)
- ]
- )
- ).
+ [
+ <<"/index/">>,
+ couch_util:url_encode(nouveau_util:index_name(Index)),
+ <<"/doc/">>,
+ couch_util:url_encode(DocId)
+ ].
-search_path(IndexName) ->
- index_path(IndexName) ++ "/search".
+search_path(#index{} = Index) ->
+ [<<"/index/">>, couch_util:url_encode(nouveau_util:index_name(Index)), <<"/search">>].
jaxrs_error(400, Body) ->
{bad_request, message(Body)};
(couchdb) 02/05: Minor couch_btree refactoring
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 9bb9374489838acd30995875017a7e4494512910
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Thu Aug 7 17:17:11 2025 -0400
Minor couch_btree refactoring
Make the #btree{} record private. There is no reason for the record to be in
the public include file.
---
src/couch/include/couch_db.hrl | 10 ----------
src/couch/src/couch_btree.erl | 24 +++++++++++++++++++++++-
src/couch/test/eunit/couch_btree_tests.erl | 11 +++++------
src/couch_mrview/src/couch_mrview_util.erl | 3 ++-
4 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/src/couch/include/couch_db.hrl b/src/couch/include/couch_db.hrl
index 9c1df21b6..138c202d5 100644
--- a/src/couch/include/couch_db.hrl
+++ b/src/couch/include/couch_db.hrl
@@ -182,16 +182,6 @@
db_open_options = []
}).
--record(btree, {
- fd,
- root,
- extract_kv,
- assemble_kv,
- less,
- reduce = nil,
- compression = ?DEFAULT_COMPRESSION
-}).
-
-record(proc, {
pid,
lang,
diff --git a/src/couch/src/couch_btree.erl b/src/couch/src/couch_btree.erl
index b974a22ee..788b5f120 100644
--- a/src/couch/src/couch_btree.erl
+++ b/src/couch/src/couch_btree.erl
@@ -14,11 +14,22 @@
-export([open/2, open/3, query_modify/4, add/2, add_remove/3]).
-export([fold/4, full_reduce/1, final_reduce/2, size/1, foldl/3, foldl/4]).
--export([fold_reduce/4, lookup/2, get_state/1, set_options/2]).
+-export([fold_reduce/4, lookup/2, set_options/2]).
+-export([is_btree/1, get_state/1, get_fd/1, get_reduce_fun/1]).
-export([extract/2, assemble/3, less/3]).
-include_lib("couch/include/couch_db.hrl").
+-record(btree, {
+ fd,
+ root,
+ extract_kv,
+ assemble_kv,
+ less,
+ reduce = nil,
+ compression = ?DEFAULT_COMPRESSION
+}).
+
-define(FILL_RATIO, 0.5).
extract(#btree{extract_kv = undefined}, Value) ->
@@ -56,9 +67,20 @@ set_options(Bt, [{compression, Comp} | Rest]) ->
open(State, Fd, Options) ->
{ok, set_options(#btree{root = State, fd = Fd}, Options)}.
+is_btree(#btree{}) ->
+ true;
+is_btree(_) ->
+ false.
+
get_state(#btree{root = Root}) ->
Root.
+get_fd(#btree{fd = Fd}) ->
+ Fd.
+
+get_reduce_fun(#btree{reduce = Reduce}) ->
+ Reduce.
+
final_reduce(#btree{reduce = Reduce}, Val) ->
final_reduce(Reduce, Val);
final_reduce(Reduce, {[], []}) ->
diff --git a/src/couch/test/eunit/couch_btree_tests.erl b/src/couch/test/eunit/couch_btree_tests.erl
index 1ec92818b..740196518 100644
--- a/src/couch/test/eunit/couch_btree_tests.erl
+++ b/src/couch/test/eunit/couch_btree_tests.erl
@@ -13,7 +13,6 @@
-module(couch_btree_tests).
-include_lib("couch/include/couch_eunit.hrl").
--include_lib("couch/include/couch_db.hrl").
-define(ROWS, 1000).
% seconds
@@ -81,7 +80,7 @@ btree_open_test_() ->
{ok, Btree} = couch_btree:open(nil, Fd, [{compression, none}]),
{
"Ensure that created btree is really a btree record",
- ?_assert(is_record(Btree, btree))
+ ?_assert(couch_btree:is_btree(Btree))
}.
sorted_kvs_test_() ->
@@ -189,10 +188,10 @@ reductions_test_() ->
}.
should_set_fd_correctly(_, {Fd, Btree}) ->
- ?_assertMatch(Fd, Btree#btree.fd).
+ ?_assertMatch(Fd, couch_btree:get_fd(Btree)).
should_set_root_correctly(_, {_, Btree}) ->
- ?_assertMatch(nil, Btree#btree.root).
+ ?_assertMatch(nil, couch_btree:get_state(Btree)).
should_create_zero_sized_btree(_, {_, Btree}) ->
?_assertMatch(0, couch_btree:size(Btree)).
@@ -200,7 +199,7 @@ should_create_zero_sized_btree(_, {_, Btree}) ->
should_set_reduce_option(_, {_, Btree}) ->
ReduceFun = fun reduce_fun/2,
Btree1 = couch_btree:set_options(Btree, [{reduce, ReduceFun}]),
- ?_assertMatch(ReduceFun, Btree1#btree.reduce).
+ ?_assertMatch(ReduceFun, couch_btree:get_reduce_fun(Btree1)).
should_fold_over_empty_btree(_, {_, Btree}) ->
{ok, _, EmptyRes} = couch_btree:foldl(Btree, fun(_, X) -> {ok, X + 1} end, 0),
@@ -228,7 +227,7 @@ should_have_lesser_size_than_file(Fd, Btree) ->
should_keep_root_pointer_to_kp_node(Fd, Btree) ->
?_assertMatch(
{ok, {kp_node, _}},
- couch_file:pread_term(Fd, element(1, Btree#btree.root))
+ couch_file:pread_term(Fd, element(1, couch_btree:get_state(Btree)))
).
should_remove_all_keys(KeyValues, Btree) ->
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index 03e35687e..eb176d365 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -1317,7 +1317,8 @@ make_user_reds_reduce_fun(Lang, ReduceFuns, NthRed) ->
get_btree_state(nil) ->
nil;
-get_btree_state(#btree{} = Btree) ->
+get_btree_state(Btree) ->
+ true = couch_btree:is_btree(Btree),
couch_btree:get_state(Btree).
extract_view_reduce({red, {N, _Lang, #mrview{reduce_funs = Reds}}, _Ref}) ->
(couchdb) 01/05: Use copy_props in the compactor instead of set_props
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-improvements
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4cc9c2b4cf31fdd43e30814fd60c43a4194efe20
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Thu Aug 7 11:48:18 2025 -0400
Use copy_props in the compactor instead of set_props
Previously, compactor used set_props/2 insead of copy_props/2. The difference
is set_props/2 also advances the update sequence, while copy_props/2 doesn't.
However, we should not do that when we copy security and props in the
compactor. In this case it turned to be a benign issue since immediately after
the update sequence is reset anyway to the one from the old state the following
snippet:
```
FinalUpdateSeq = couch_bt_engine:get_update_seq(St)
{ok, NewSt6} = couch_bt_engine:set_update_seq(NewSt5, FinalUpdateSeq)
```
---
src/couch/src/couch_bt_engine_compactor.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/couch/src/couch_bt_engine_compactor.erl b/src/couch/src/couch_bt_engine_compactor.erl
index 8ed55b5c3..f16ae4184 100644
--- a/src/couch/src/couch_bt_engine_compactor.erl
+++ b/src/couch/src/couch_bt_engine_compactor.erl
@@ -381,7 +381,7 @@ copy_compact(#comp_st{} = CompSt) ->
% Copy general properties over
Props = couch_bt_engine:get_props(St),
- {ok, NewSt5} = couch_bt_engine:set_props(NewSt4, Props),
+ {ok, NewSt5} = couch_bt_engine:copy_props(NewSt4, Props),
FinalUpdateSeq = couch_bt_engine:get_update_seq(St),
{ok, NewSt6} = couch_bt_engine:set_update_seq(NewSt5, FinalUpdateSeq),