couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r754982 - in /couchdb/trunk/src/couchdb: couch_btree.erl couch_file.erl
Date Mon, 16 Mar 2009 19:14:37 GMT
Author: damien
Date: Mon Mar 16 19:14:37 2009
New Revision: 754982

URL: http://svn.apache.org/viewvc?rev=754982&view=rev
Log:
Fix for problem with btree folds getting incorrect reductions after the first value.

Modified:
    couchdb/trunk/src/couchdb/couch_btree.erl
    couchdb/trunk/src/couchdb/couch_file.erl

Modified: couchdb/trunk/src/couchdb/couch_btree.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_btree.erl?rev=754982&r1=754981&r2=754982&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_btree.erl (original)
+++ couchdb/trunk/src/couchdb/couch_btree.erl Mon Mar 16 19:14:37 2009
@@ -597,7 +597,7 @@
 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 @@
     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 @@
     % 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,

Modified: couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=754982&r1=754981&r2=754982&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ couchdb/trunk/src/couchdb/couch_file.erl Mon Mar 16 19:14:37 2009
@@ -285,14 +285,14 @@
                 true ->
                     {ok, 0} = file:position(Fd, 0),
                     ok = file:truncate(Fd),
-                    couch_stats_collector:increment({couchdb, open_os_files}),
+                    catch couch_stats_collector:increment({couchdb, open_os_files}),
                     {ok, Fd};
                 false ->
                     ok = file:close(Fd),
                     init_status_error(ReturnPid, Ref, file_exists)
                 end;
             false ->
-                couch_stats_collector:increment({couchdb, open_os_files}),
+                catch couch_stats_collector:increment({couchdb, open_os_files}),
                 {ok, Fd}
             end;
         Error ->
@@ -304,7 +304,7 @@
         {ok, Fd_Read} ->
             {ok, Fd} = file:open(Filepath, [read, write, raw, binary]),
             ok = file:close(Fd_Read),
-            couch_stats_collector:increment({couchdb, open_os_files}),
+            catch couch_stats_collector:increment({couchdb, open_os_files}),
             {ok, Fd};
         Error ->
             init_status_error(ReturnPid, Ref, Error)
@@ -313,7 +313,7 @@
 
 
 terminate(_Reason, _Fd) ->
-    couch_stats_collector:decrement({couchdb, open_os_files}),
+    catch couch_stats_collector:decrement({couchdb, open_os_files}),
     ok.
 
 



Mime
View raw message