diff options
author | Damien F. Katz <damien@apache.org> | 2009-03-16 19:14:37 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-03-16 19:14:37 +0000 |
commit | 41841a800df5922133648d82a9f5dd5ec2562b42 (patch) | |
tree | 4842cf75fe8cd1868f4735dd755add87d1adb372 /src/couchdb/couch_btree.erl | |
parent | 2adbe68f0922aa2f2d0d8d4af35c4d96534730d6 (diff) |
Fix for problem with btree folds getting incorrect reductions after the first value.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@754982 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_btree.erl')
-rw-r--r-- | src/couchdb/couch_btree.erl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/couchdb/couch_btree.erl b/src/couchdb/couch_btree.erl index f2212aa0..4c94a68c 100644 --- a/src/couchdb/couch_btree.erl +++ b/src/couchdb/couch_btree.erl @@ -597,7 +597,7 @@ drop_nodes(_Bt, Reds, _StartKey, []) -> drop_nodes(Bt, Reds, StartKey, [{NodeKey, {Pointer, Red}} | RestKPs]) -> case less(Bt, NodeKey, StartKey) of true -> drop_nodes(Bt, [Red | Reds], StartKey, RestKPs); - false -> {Reds, [{NodeKey, {Pointer, Reds}} | RestKPs]} + false -> {Reds, [{NodeKey, {Pointer, Red}} | RestKPs]} end. stream_kp_node(Bt, Reds, KPs, StartKey, Dir, Fun, Acc) -> @@ -621,10 +621,10 @@ stream_kp_node(Bt, Reds, KPs, StartKey, Dir, Fun, Acc) -> case NodesToStream of [] -> {ok, Acc}; - [{_Key, PointerInfo} | Rest] -> - case stream_node(Bt, NewReds, PointerInfo, StartKey, Dir, Fun, Acc) of + [{_Key, {Pointer, Red}} | Rest] -> + case stream_node(Bt, NewReds, {Pointer, Red}, StartKey, Dir, Fun, Acc) of {ok, Acc2} -> - stream_kp_node(Bt, NewReds, Rest, Dir, Fun, Acc2); + stream_kp_node(Bt, [Red | NewReds], Rest, Dir, Fun, Acc2); {stop, Acc2} -> {stop, Acc2} end @@ -703,12 +703,13 @@ test_btree(KeyValues) -> % get the leading reduction as we foldl/r % and count of all from start to Val1 Val1 = Len div 3, - {ok, true} = foldl(Btree10, Val1, fun(_X, LeadingReds, _Acc) -> - CountToStart = Val1 - 1, + {ok, _} = foldl(Btree10, Val1, + fun(_X, LeadingReds, Acc) -> + CountToStart = Val1 + Acc - 1, CountToStart = final_reduce(Btree10, LeadingReds), - {stop, true} % change Acc to 'true' + {ok, Acc + 1} end, - false), + 0), {ok, true} = foldr(Btree10, Val1, fun(_X, LeadingReds, _Acc) -> CountToEnd = Len - Val1, |