Github user iilyak commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-index/pull/16#discussion_r63967414
  
    --- Diff: src/couch_index.erl ---
    @@ -407,3 +394,160 @@ assert_signature_match(Mod, OldIdxState, NewIdxState) 
->
             {Sig, Sig} -> ok;
             _ -> erlang:error(signature_mismatch)
         end.
    +
    +commit_compacted(NewIdxState, State) ->
    +    #st{
    +        mod=Mod,
    +        idx_state=OldIdxState,
    +        updater=Updater,
    +        commit_delay=Delay
    +    } = State,
    +    {ok, NewIdxState1} = Mod:swap_compacted(OldIdxState, NewIdxState),
    +    % Restart the indexer if it's running.
    +    case couch_index_updater:is_running(Updater) of
    +        true -> ok = couch_index_updater:restart(Updater, NewIdxState1);
    +        false -> ok
    +    end,
    +    case State#st.committed of
    +        true -> erlang:send_after(Delay, self(), commit);
    +        false -> ok
    +    end,
    +    State#st{
    +        idx_state=NewIdxState1,
    +        committed=false
    +     }.
    +
    +is_recompaction_enabled(IdxState, #st{mod = Mod}) ->
    +    DbName = binary_to_list(Mod:get(db_name, IdxState)),
    +    IdxName = binary_to_list(Mod:get(idx_name, IdxState)),
    +    IdxKey = DbName ++ ":" ++ IdxName,
    +    Global = config:get("view_compaction.recompaction", "enable"),
    +    PerIndex = config:get("view_compaction.recompaction", IdxKey),
    +    PerDb = config:get("view_compaction.recompaction", DbName),
    +    case {Global, PerDb, PerIndex} of
    --- End diff --
    
    It is about defaults. By default recompaction should be enabled. We also 
need to distinguish between default and user provided value. There are two 
major modes:
    
    1. when `view_compaction.enable_recompaction = true`
       In this case we can set `view_recompaction.DbName:IdxName.enable = 
false` to ***disable*** `recompact`.
    
    1. when `view_compaction.enable_recompaction = false`
       In this case we can set `view_recompaction.DbName:IdxName.enable = true` 
to ***enable*** `recompact`.
    
    Although I agree the case statement is hard to follow. I'll simplify the 
condition.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to