Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
support for compacting shards missing design docs (issue#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Dionne committed Nov 23, 2010
1 parent 2114a65 commit a44336c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/couch/src/couch_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ get_group_server(DbName, GroupId) ->
% get signature for group
case couch_view_group:open_db_group(DbName, GroupId) of
% do we need to close this db?
{ok, _Db, Group} ->
{ok, Group} ->
case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
{ok, Pid} ->
Pid;
Expand Down
31 changes: 15 additions & 16 deletions apps/couch/src/couch_view_group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ handle_info({'EXIT', FromPid, reset}, #group_state{init_args=InitArgs,
handle_info({'EXIT', _, reset}, State) ->
%% message from an old (probably pre-compaction) updater; ignore
{noreply, State};

handle_info({'EXIT', _FromPid, normal}, State) ->
{noreply, State};

Expand Down Expand Up @@ -440,18 +440,17 @@ set_view_sig(#group{
G#group{sig=couch_util:md5(term_to_binary({Views, Language, DesignOptions}))}.

open_db_group(DbName, GroupId) ->
case couch_db:open_int(DbName, []) of
{ok, Db} ->
case couch_db:open_doc(Db, GroupId) of
{ok, Doc} ->
{ok, Db, design_doc_to_view_group(Doc)};
Else ->
couch_db:close(Db),
Else
end;
Else ->
Else
end.
FullDbName = mem3_util:extract_db_name(DbName),
{Pid, Ref} =
spawn_monitor(fun() ->
exit(fabric:open_doc(FullDbName,
GroupId, []))
end),
{ok, Doc} =
receive {'DOWN',Ref,process,Pid, Resp} ->
Resp
end,
{ok, design_doc_to_view_group(Doc)}.

get_group_info(State) ->
#group_state{
Expand Down Expand Up @@ -570,17 +569,17 @@ init_group(Fd, #group{def_lang=Lang,views=Views}=Group, IndexHeader) ->
UserReds),
{Count, Reduced}
end,

case couch_util:get_value(<<"collation">>, Options, <<"default">>) of
<<"default">> ->
Less = fun couch_view:less_json_ids/2;
<<"raw">> ->
Less = fun(A,B) -> A < B end
end,

BTreeChunkSize = list_to_integer(couch_config:get("couchdb",
"btree_chunk_size", "1279")),

{ok, Btree} = couch_btree:open(BtreeState, Fd, [{less, Less},
{reduce, ReduceFun},
{chunk_size, BTreeChunkSize}]),
Expand Down

0 comments on commit a44336c

Please sign in to comment.