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 2008/05/23 18:51:47 UTC
svn commit: r659596 - in /incubator/couchdb/trunk: share/server/main.js
src/couchdb/couch_btree.erl src/couchdb/couch_view.erl
Author: damien
Date: Fri May 23 09:51:46 2008
New Revision: 659596
URL: http://svn.apache.org/viewvc?rev=659596&view=rev
Log:
fix for bug with reusing map btree indexes when multiple views have the same map function
Modified:
incubator/couchdb/trunk/share/server/main.js
incubator/couchdb/trunk/src/couchdb/couch_btree.erl
incubator/couchdb/trunk/src/couchdb/couch_view.erl
Modified: incubator/couchdb/trunk/share/server/main.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/server/main.js?rev=659596&r1=659595&r2=659596&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/server/main.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/server/main.js [utf-8] Fri May 23 09:51:46 2008
@@ -104,11 +104,12 @@
var values = null;
var reduceFuns = cmd[1];
var is_combine = false;
+
if (cmd[0] == "reduce") {
var kvs = cmd[2];
keys = new Array(kvs.length);
values = new Array(kvs.length);
- for (var i = 0; i < kvs.length; i++) {
+ for(var i = 0; i < kvs.length; i++) {
keys[i] = kvs[i][0];
values[i] = kvs[i][1];
}
@@ -122,7 +123,7 @@
}
var reductions = new Array(funs.length);
- for (var i = 0; i < reduceFuns.length; i++) {
+ for(var i = 0; i < reduceFuns.length; i++) {
try {
reductions[i] = reduceFuns[i](keys, values, is_combine);
} catch (err) {
Modified: incubator/couchdb/trunk/src/couchdb/couch_btree.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_btree.erl?rev=659596&r1=659595&r2=659596&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_btree.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_btree.erl Fri May 23 09:51:46 2008
@@ -390,40 +390,42 @@
end.
+collect_node(_Bt, {P, R}, nil, nil) ->
+ {[], [{nil, {P,R}}]};
collect_node(Bt, {P, R}, KeyStart, KeyEnd) ->
case get_node(Bt, P) of
{kp_node, NodeList} ->
collect_kp_node(Bt, NodeList, KeyStart, KeyEnd);
{kv_node, KVs} ->
- GTEKeyStartKVs =
- case KeyStart of
- nil ->
- KVs;
- _ ->
- lists:dropwhile(
- fun({Key,_}) ->
- less(Bt, Key, KeyStart)
- end, KVs)
- end,
- KVs2 =
- case KeyEnd of
- nil ->
- GTEKeyStartKVs;
- _ ->
- lists:dropwhile(
- fun({Key,_}) ->
- less(Bt, KeyEnd, Key)
- end, lists:reverse(GTEKeyStartKVs))
- end,
- case length(KVs2) == length(KVs) of
- true -> % got full node, return the already calculated reduction
- {[], [{nil, {P, R}}]};
- false -> % otherwise return the keyvalues for later reduction
- {[assemble(Bt,K,V) || {K,V} <- KVs2], []}
- end
+ collect_kv_node(Bt, {P,R}, KVs, KeyStart, KeyEnd)
end.
-
+collect_kv_node(Bt, {P,R}, KVs, KeyStart, KeyEnd) ->
+ GTEKeyStartKVs =
+ case KeyStart of
+ nil ->
+ KVs;
+ _ ->
+ lists:dropwhile(fun({Key,_}) -> less(Bt, Key, KeyStart) end, KVs)
+ end,
+ KVs2 =
+ case KeyEnd of
+ nil ->
+ GTEKeyStartKVs;
+ _ ->
+ lists:dropwhile(
+ fun({Key,_}) ->
+ less(Bt, KeyEnd, Key)
+ end, lists:reverse(GTEKeyStartKVs))
+ end,
+ case length(KVs2) == length(KVs) of
+ true -> % got full node, return the already calculated reduction
+ {[], [{nil, {P, R}}]};
+ false -> % otherwise return the keyvalues for later reduction
+ {[assemble(Bt,K,V) || {K,V} <- KVs2], []}
+ end.
+
+
collect_kp_node(Bt, NodeList, KeyStart, KeyEnd) ->
Nodes =
case KeyStart of
Modified: incubator/couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_view.erl?rev=659596&r1=659595&r2=659596&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_view.erl Fri May 23 09:51:46 2008
@@ -116,8 +116,8 @@
{ok, Reduced} = couch_query_servers:combine(Lang, [FunSrc], UserReds),
{0, PreResultPadding ++ Reduced ++ PostResultPadding}
end,
- {_, [FinalReduction]} = couch_btree:final_reduce(ReduceFun, PartialReductions),
- {ok, FinalReduction}.
+ {_, FinalReds} = couch_btree:final_reduce(ReduceFun, PartialReductions),
+ {ok, lists:nth(NthRed, FinalReds)}.
get_key_pos(_Key, [], _N) ->
0;