You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/11/02 21:14:37 UTC
[couchdb] branch optimize-doc-updates updated (65902dc -> 6853c32)
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a change to branch optimize-doc-updates
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
from 65902dc Optimize couch_key_tree:stem/2
new 26214e0 Fix should_merge_tree_to_itself test
new 2c2bf4f Fix should_merge_tree_of_odd_length test
new 6853c32 Fix should_create_no_conflicts_on_merge test
The 3 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.
Summary of changes:
src/couch/test/couch_key_tree_tests.erl | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].
[couchdb] 03/03: Fix should_create_no_conflicts_on_merge test
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch optimize-doc-updates
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 6853c32934e949ba75b579ae6eda1f7dae27de10
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Nov 2 16:13:48 2017 -0500
Fix should_create_no_conflicts_on_merge test
This test is actually testing that the old stemming algorithm with
correct a badly formatted tree after a revision had been incorrectly
merged. This is no renamed `full_stem` which only happens at compaction
time.
---
src/couch/test/couch_key_tree_tests.erl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/couch/test/couch_key_tree_tests.erl b/src/couch/test/couch_key_tree_tests.erl
index 97ef33d..f555ff7 100644
--- a/src/couch/test/couch_key_tree_tests.erl
+++ b/src/couch/test/couch_key_tree_tests.erl
@@ -40,7 +40,7 @@ key_tree_merge_test_()->
should_merge_tree_with_large_stem(),
should_merge_stems(),
should_create_conflicts_on_merge(),
- should_create_no_conflicts_on_merge(),
+ should_create_no_conflicts_on_full_stem(),
should_ignore_conflicting_branch()
]
}
@@ -236,12 +236,12 @@ should_create_conflicts_on_merge()->
?_assertEqual({[OneChild, Stemmed], new_branch},
couch_key_tree:merge([OneChild], Stemmed, ?DEPTH)).
-should_create_no_conflicts_on_merge()->
+should_create_no_conflicts_on_full_stem()->
OneChild = {1, {"1","foo",[{"1a", "bar", []}]}},
Stemmed = {3, {"1aa", "bar", []}},
TwoChild = {1, {"1","foo", [{"1a", "bar", [{"1aa", "bar", []}]}]}},
- ?_assertEqual({[TwoChild], new_leaf},
- couch_key_tree:merge([OneChild, Stemmed], TwoChild, ?DEPTH)).
+ {Merged, new_leaf} = couch_key_tree:merge([OneChild, Stemmed], TwoChild),
+ ?_assertEqual([TwoChild], couch_key_tree:full_stem(Merged, ?DEPTH)).
should_ignore_conflicting_branch()->
%% this test is based on couch-902-test-case2.py
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 01/03: Fix should_merge_tree_to_itself test
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch optimize-doc-updates
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 26214e09b50230550e7cb3b1dec8528a7b31de0b
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Nov 2 16:09:36 2017 -0500
Fix should_merge_tree_to_itself test
This test was invalid as merging does not support anything other than a
linear path. The fact that this was passing before is merely and
oversight that was covered up by stemming completely disassembling and
reassembling the tree after a failed merge.
---
src/couch/test/couch_key_tree_tests.erl | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/couch/test/couch_key_tree_tests.erl b/src/couch/test/couch_key_tree_tests.erl
index 8aa886f..fb332d1 100644
--- a/src/couch/test/couch_key_tree_tests.erl
+++ b/src/couch/test/couch_key_tree_tests.erl
@@ -163,8 +163,23 @@ should_merge_reflexive_for_child_nodes()->
should_merge_tree_to_itself()->
TwoChildSibs = {1, {"1","foo", [{"1a", "bar", []},
{"1b", "bar", []}]}},
- ?_assertEqual({[TwoChildSibs], new_branch},
- couch_key_tree:merge([TwoChildSibs], TwoChildSibs, ?DEPTH)).
+ Leafs = couch_key_tree:get_all_leafs([TwoChildSibs]),
+ Paths = lists:map(fun leaf_to_path/1, Leafs),
+ FinalTree = lists:foldl(fun(Path, TreeAcc) ->
+ {NewTree, internal_node} = couch_key_tree:merge(TreeAcc, Path),
+ NewTree
+ end, [TwoChildSibs], Paths),
+ ?_assertEqual([TwoChildSibs], FinalTree).
+
+leaf_to_path({Value, {Start, Keys}}) ->
+ [Branch] = to_branch(Value, lists:reverse(Keys)),
+ {Start - length(Keys) + 1, Branch}.
+
+to_branch(Value, [Key]) ->
+ [{Key, Value, []}];
+to_branch(Value, [Key | RestKeys]) ->
+ [{Key, [], to_branch(Value, RestKeys)}].
+
should_merge_tree_of_odd_length()->
TwoChild = {1, {"1","foo", [{"1a", "bar", [{"1aa", "bar", []}]}]}},
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 02/03: Fix should_merge_tree_of_odd_length test
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch optimize-doc-updates
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2c2bf4fa48e3ee6a5427b1f266e852cc3a0a7852
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Nov 2 16:11:03 2017 -0500
Fix should_merge_tree_of_odd_length test
This test was invalid as merging does not support anything but a linear
path. This merge failure was covered up by stemming completely
disassembling and reassembling the badly merged tree.
---
src/couch/test/couch_key_tree_tests.erl | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/couch/test/couch_key_tree_tests.erl b/src/couch/test/couch_key_tree_tests.erl
index fb332d1..97ef33d 100644
--- a/src/couch/test/couch_key_tree_tests.erl
+++ b/src/couch/test/couch_key_tree_tests.erl
@@ -187,9 +187,8 @@ should_merge_tree_of_odd_length()->
{"1b", "bar", []}]}},
TwoChildPlusSibs = {1, {"1","foo", [{"1a", "bar", [{"1aa", "bar", []}]},
{"1b", "bar", []}]}},
-
- ?_assertEqual({[TwoChildPlusSibs], new_branch},
- couch_key_tree:merge([TwoChild], TwoChildSibs, ?DEPTH)).
+ ?_assertEqual({[TwoChildPlusSibs], new_leaf},
+ couch_key_tree:merge([TwoChildSibs], TwoChild, ?DEPTH)).
should_merge_tree_with_stem()->
Stemmed = {2, {"1a", "bar", []}},
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.