couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1006345 - /couchdb/trunk/src/couchdb/couch_view_group.erl
Date Sun, 10 Oct 2010 19:44:01 GMT
Author: davisp
Date: Sun Oct 10 19:44:01 2010
New Revision: 1006345

URL: http://svn.apache.org/viewvc?rev=1006345&view=rev
Log:
Avoid view regeneration for new ETags support.
        
This reverts the group signature calculation to use a tuple that
would've been generated before changing the view record definition.
New ETag's will automatically be supported when people run their
next index update.


Modified:
    couchdb/trunk/src/couchdb/couch_view_group.erl

Modified: couchdb/trunk/src/couchdb/couch_view_group.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view_group.erl?rev=1006345&r1=1006344&r2=1006345&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_view_group.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view_group.erl Sun Oct 10 19:44:01 2010
@@ -464,16 +464,28 @@ set_view_sig(#group{
             lib={[]},
             def_lang=Language,
             design_options=DesignOptions}=G) ->
-    ViewInfo = [V#view{update_seq=0, purge_seq=0} || V <- Views],
+    ViewInfo = [old_view_format(V) || V <- Views],
     G#group{sig=couch_util:md5(term_to_binary({ViewInfo, Language, DesignOptions}))};
 set_view_sig(#group{
             views=Views,
             lib=Lib,
             def_lang=Language,
             design_options=DesignOptions}=G) ->
-    ViewInfo = [V#view{update_seq=0, purge_seq=0} || V <- Views],
+    ViewInfo = [old_view_format(V) || V <- Views],
     G#group{sig=couch_util:md5(term_to_binary({ViewInfo, Language, DesignOptions, sort_lib(Lib)}))}.
 
+% Use the old view record format so group sig's don't change
+old_view_format(View) ->
+    {
+        view,
+        View#view.id_num,
+        View#view.map_names,
+        View#view.def,
+        View#view.btree,
+        View#view.reduce_funs,
+        View#view.options
+    }.
+
 sort_lib({Lib}) ->
     sort_lib(Lib, []).
 sort_lib([], LAcc) ->
@@ -585,6 +597,11 @@ init_group(Db, Fd, #group{def_lang=Lang,
             Group, IndexHeader) ->
      #index_header{seq=Seq, purge_seq=PurgeSeq,
             id_btree_state=IdBtreeState, view_states=ViewStates} = IndexHeader,
+    StateUpdate = fun
+        ({_, _, _}=State) -> State;
+        (State) -> {State, 0, 0}
+    end,
+    ViewStates2 = lists:map(StateUpdate, ViewStates),
     {ok, IdBtree} = couch_btree:open(IdBtreeState, Fd),
     Views2 = lists:zipwith(
         fun({BTState, USeq, PSeq}, #view{reduce_funs=RedFuns,options=Options}=View) ->
@@ -615,7 +632,7 @@ init_group(Db, Fd, #group{def_lang=Lang,
             ),
             View#view{btree=Btree, update_seq=USeq, purge_seq=PSeq}
         end,
-        ViewStates, Views),
+        ViewStates2, Views),
     Group#group{db=Db, fd=Fd, current_seq=Seq, purge_seq=PurgeSeq,
         id_btree=IdBtree, views=Views2}.
 



Mime
View raw message