You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2010/12/29 04:38:05 UTC

svn commit: r1053525 - in /couchdb/branches/0.11.x: src/couchdb/couch_key_tree.erl test/etap/060-kt-merging.t

Author: kocolosk
Date: Wed Dec 29 03:38:05 2010
New Revision: 1053525

URL: http://svn.apache.org/viewvc?rev=1053525&view=rev
Log:
Skip recursive path merging, COUCHDB-968

This patch ensures that we only ever merge a linear path into the tree.
It relies on the stemming code to collapse paths that could have been
merged together by a recursive use of merge_one.

Modified:
    couchdb/branches/0.11.x/src/couchdb/couch_key_tree.erl
    couchdb/branches/0.11.x/test/etap/060-kt-merging.t

Modified: couchdb/branches/0.11.x/src/couchdb/couch_key_tree.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_key_tree.erl?rev=1053525&r1=1053524&r2=1053525&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_key_tree.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_key_tree.erl Wed Dec 29 03:38:05 2010
@@ -43,7 +43,7 @@ merge_one([{Start, Tree}|Rest], {StartIn
     case merge_at([Tree], StartInsert - Start, [TreeInsert]) of
     {ok, [Merged], Conflicts} ->
         MergedStart = lists:min([Start, StartInsert]),
-        merge_one(Rest, {MergedStart, Merged}, Acc, Conflicts or HasConflicts);
+        {ok, Rest ++ [{MergedStart, Merged} | Acc], Conflicts or HasConflicts};
     no ->
         AccOut = [{Start, Tree} | Acc],
         merge_one(Rest, {StartInsert, TreeInsert}, AccOut, HasConflicts)

Modified: couchdb/branches/0.11.x/test/etap/060-kt-merging.t
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/test/etap/060-kt-merging.t?rev=1053525&r1=1053524&r2=1053525&view=diff
==============================================================================
--- couchdb/branches/0.11.x/test/etap/060-kt-merging.t (original)
+++ couchdb/branches/0.11.x/test/etap/060-kt-merging.t Wed Dec 29 03:38:05 2010
@@ -15,7 +15,7 @@
 
 main(_) ->
     test_util:init_code_path(),
-    etap:plan(12),
+    etap:plan(14),
     case (catch test()) of
         ok ->
             etap:end_tests();
@@ -106,10 +106,13 @@ test() ->
         "Merging should create conflicts."
     ),
 
-    etap:is(
-        {[TwoChild], no_conflicts},
-        couch_key_tree:merge(Expect1, TwoChild),
-        "Merge should have no conflicts."
+    {MultiPaths, NoConflicts} = couch_key_tree:merge(Expect1, TwoChild),
+    etap:is(NoConflicts, no_conflicts, "Merge should have no conflicts."),
+    etap:is(length(MultiPaths), 2, "Should have two paths before stemming."),
+    etap:is(
+        couch_key_tree:stem(MultiPaths, 10),
+        [TwoChild],
+        "Stemming should collapse the paths."
     ),
 
     ok.