You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2020/03/02 08:21:57 UTC
[couchdb] 03/05: fixes from review
This is an automated email from the ASF dual-hosted git repository.
garren pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 89dd96893885cab3e9c994475a1efa22aa7b39c3
Author: Garren Smith <ga...@gmail.com>
AuthorDate: Wed Feb 26 09:56:32 2020 +0200
fixes from review
---
rel/overlay/etc/default.ini | 2 +-
src/couch_views/src/couch_views_fdb.erl | 8 +-
src/couch_views/test/couch_views_indexer_test.erl | 89 ++++++++---------------
3 files changed, 37 insertions(+), 62 deletions(-)
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 2b9178c..6b60676 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -252,7 +252,7 @@ iterations = 10 ; iterations for password hashing
; The maximum allowed key size emitted from a view for a document (in bytes)
; key_size_limit = 8000
; The maximum allowed value size emitted from a view for a document (in bytes)
-; key_size_limit = 64000
+; value_size_limit = 64000
; CSP (Content Security Policy) Support for _utils
[csp]
diff --git a/src/couch_views/src/couch_views_fdb.erl b/src/couch_views/src/couch_views_fdb.erl
index 0bde4c2..ed0122e 100644
--- a/src/couch_views/src/couch_views_fdb.erl
+++ b/src/couch_views/src/couch_views_fdb.erl
@@ -161,8 +161,12 @@ write_doc(TxDb, Sig, Views, Doc) ->
ExistingViewKey ->
remove_doc_from_idx(TxDb, Sig, DocId, ExistingViewKey)
end,
- couch_log:error("Doc `~s` exceeded the ~s size for view `~s`"
- " and was not indexed.", [DocId, Type, MNames])
+ #{
+ name := DbName
+ } = TxDb,
+ couch_log:error("Db `~s` Doc `~s` exceeded the ~s size"
+ "for view `~s` and was not indexed.",
+ [DbName, DocId, Type, MNames])
end
end, lists:zip(Views, Results)).
diff --git a/src/couch_views/test/couch_views_indexer_test.erl b/src/couch_views/test/couch_views_indexer_test.erl
index aa544d1..17adc42 100644
--- a/src/couch_views/test/couch_views_indexer_test.erl
+++ b/src/couch_views/test/couch_views_indexer_test.erl
@@ -30,17 +30,17 @@ indexer_test_() ->
fun foreach_setup/0,
fun foreach_teardown/1,
[
- with([?TDEF(indexed_empty_db)]),
- with([?TDEF(indexed_single_doc)]),
- with([?TDEF(updated_docs_are_reindexed)]),
- with([?TDEF(updated_docs_without_changes_are_reindexed)]),
- with([?TDEF(deleted_docs_not_indexed)]),
- with([?TDEF(deleted_docs_are_unindexed)]),
- with([?TDEF(multipe_docs_with_same_key)]),
- with([?TDEF(multipe_keys_from_same_doc)]),
- with([?TDEF(multipe_identical_keys_from_same_doc)]),
- with([?TDEF(handle_size_key_limits)]),
- with([?TDEF(handle_size_value_limits)])
+ ?TDEF_FE(indexed_empty_db),
+ ?TDEF_FE(indexed_single_doc),
+ ?TDEF_FE(updated_docs_are_reindexed),
+ ?TDEF_FE(updated_docs_without_changes_are_reindexed),
+ ?TDEF_FE(deleted_docs_not_indexed),
+ ?TDEF_FE(deleted_docs_are_unindexed),
+ ?TDEF_FE(multipe_docs_with_same_key),
+ ?TDEF_FE(multipe_keys_from_same_doc),
+ ?TDEF_FE(multipe_identical_keys_from_same_doc),
+ ?TDEF_FE(handle_size_key_limits),
+ ?TDEF_FE(handle_size_value_limits)
]
}
}
@@ -390,9 +390,9 @@ multipe_identical_keys_from_same_doc(Db) ->
handle_size_key_limits(Db) ->
ok = meck:new(config, [passthrough]),
- ok = meck:expect(config, get_integer, fun(Section, _, Default) ->
- case Section of
- "couch_views" -> 15;
+ ok = meck:expect(config, get_integer, fun(Section, Key, Default) ->
+ case Section == "couch_views" andalso Key == "key_size_limit" of
+ true -> 15;
_ -> Default
end
end),
@@ -412,11 +412,7 @@ handle_size_key_limits(Db) ->
),
?assertEqual([
- {row, [
- {id, <<"1">>},
- {key, 1},
- {value, 1}
- ]}
+ row(<<"1">>, 1, 1)
], Out),
{ok, Doc} = fabric2_db:open_doc(Db, <<"2">>),
@@ -435,16 +431,8 @@ handle_size_key_limits(Db) ->
),
?assertEqual([
- {row, [
- {id, <<"1">>},
- {key, 1},
- {value, 1}
- ]},
- {row, [
- {id, <<"2">>},
- {key, 3},
- {value, 3}
- ]}
+ row(<<"1">>, 1, 1),
+ row(<<"2">>, 3, 3)
], Out1).
@@ -472,26 +460,10 @@ handle_size_value_limits(Db) ->
),
?assertEqual([
- {row, [
- {id, <<"1">>},
- {key, 2},
- {value, 2}
- ]},
- {row, [
- {id, <<"2">>},
- {key, 3},
- {value, 3}
- ]},
- {row, [
- {id, <<"1">>},
- {key, 22},
- {value, 2}
- ]},
- {row, [
- {id, <<"2">>},
- {key, 23},
- {value, 3}
- ]}
+ row(<<"1">>, 2, 2),
+ row(<<"2">>, 3, 3),
+ row(<<"1">>, 22, 2),
+ row(<<"2">>, 23, 3)
], Out),
@@ -511,19 +483,18 @@ handle_size_value_limits(Db) ->
),
?assertEqual([
- {row, [
- {id, <<"2">>},
- {key, 3},
- {value, 3}
- ]},
- {row, [
- {id, <<"2">>},
- {key, 23},
- {value, 3}
- ]}
+ row(<<"2">>, 3, 3),
+ row(<<"2">>, 23, 3)
], Out1).
+row(Id, Key, Value) ->
+ {row, [
+ {id, Id},
+ {key, Key},
+ {value, Value}
+ ]}.
+
fold_fun({meta, _Meta}, Acc) ->
{ok, Acc};
fold_fun({row, _} = Row, Acc) ->