nickva commented on code in PR #5896:
URL: https://github.com/apache/couchdb/pull/5896#discussion_r2925196758
##########
src/nouveau/src/nouveau_index_updater.erl:
##########
@@ -214,46 +255,45 @@ purge_index(Db, Index, #purge_acc{} = PurgeAcc0) ->
try
true = proc_prompt(Proc, [<<"add_fun">>, Index#index.def,
<<"nouveau">>]),
FoldFun = fun({PurgeSeq, _UUID, Id, _Revs}, #purge_acc{} = PurgeAcc1)
->
- PurgeAcc2 =
+ PurgeAcc3 =
case couch_db:get_full_doc_info(Db, Id) of
not_found ->
- ok = nouveau_api:purge_doc(
- Index, Id, PurgeAcc1#purge_acc.index_purge_seq,
PurgeSeq
+ Item = nouveau_api:make_purge(
+ Id, PurgeAcc1#purge_acc.index_purge_seq, PurgeSeq
),
- PurgeAcc1#purge_acc{index_purge_seq = PurgeSeq};
+ PurgeAcc2 = PurgeAcc1#purge_acc{batch = [Item |
PurgeAcc1#purge_acc.batch]},
+ PurgeAcc2#purge_acc{index_purge_seq = PurgeSeq};
FDI ->
DI = couch_doc:to_doc_info(FDI),
#doc_info{id = Id, high_seq = Seq, revs =
[#rev_info{rev = Rev} | _]} = DI,
case lists:member({Id, Rev},
PurgeAcc1#purge_acc.exclude_list) of
true ->
PurgeAcc1;
false ->
- update_or_delete_index(
- Db,
- Index,
- PurgeAcc1#purge_acc.index_update_seq,
- DI,
- Proc
+ Item = update_or_delete_index(
+ Db, PurgeAcc1#purge_acc.index_update_seq,
DI, Proc
),
PurgeAcc1#purge_acc{
+ batch = [Item | PurgeAcc1#purge_acc.batch],
exclude_list = [{Id, Rev} |
PurgeAcc1#purge_acc.exclude_list],
index_update_seq = Seq
}
end
end,
update_task(1),
- {ok, PurgeAcc2}
+ maybe_flush_batch(PurgeAcc3)
end,
{ok, #purge_acc{} = PurgeAcc3} = couch_db:fold_purge_infos(
Db, PurgeAcc0#purge_acc.index_purge_seq, FoldFun, PurgeAcc0, []
),
+ {ok, PurgeAcc4} = flush_batch(PurgeAcc3),
DbPurgeSeq = couch_db:get_purge_seq(Db),
ok = nouveau_api:set_purge_seq(
- Index, PurgeAcc3#purge_acc.index_purge_seq, DbPurgeSeq
+ Index, PurgeAcc4#purge_acc.index_purge_seq, DbPurgeSeq
Review Comment:
This is not new behavior in the pr, but just out of curiosity, why do we
pass in both the db purge seq and the latest index purge seq when we set the
purge seq in the index. How is this used on the java side.
I guess we expected cases where these may diverge. One I can think of is if
the last purge info was already in the `PurgeAcc1#purge_acc.exclude_list` list,
then we'd would not bump the the accumulator purge sequence. So set_purge_seq
may be called as `set_purge_seq(Index, 99, 100)`? But I can't see how that
would be useful or what it would mean on the java side).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]