Deprecate use of Bucket as a constraint in indexfold

Must also give a StartKey.  Otherwise there may be conflict when tuplebuckets are used
This commit is contained in:
Martin Sumner 2018-12-05 20:46:17 +00:00
parent f415d22ef0
commit 835955adb9
2 changed files with 16 additions and 5 deletions

View file

@ -610,13 +610,13 @@ book_returnfolder(Pid, RunnerType) ->
%% still closing down the snapshot). This may be used, for example, to %% still closing down the snapshot). This may be used, for example, to
%% curtail a fold in the application at max_results %% curtail a fold in the application at max_results
-spec book_indexfold(pid(), -spec book_indexfold(pid(),
Constraint:: {Bucket, Key} | Bucket, Constraint:: {Bucket, StartKey},
FoldAccT :: {FoldFun, Acc}, FoldAccT :: {FoldFun, Acc},
Range :: {IndexField, Start, End}, Range :: {IndexField, Start, End},
TermHandling :: {ReturnTerms, TermRegex}) -> TermHandling :: {ReturnTerms, TermRegex}) ->
{async, Runner::fun()} {async, Runner::fun()}
when Bucket::term(), when Bucket::term(),
Key::term(), StartKey::term(),
FoldFun::fun((Bucket, Key | {IndexVal, Key}, Acc) -> Acc), FoldFun::fun((Bucket, Key | {IndexVal, Key}, Acc) -> Acc),
Acc::term(), Acc::term(),
IndexField::term(), IndexField::term(),
@ -626,10 +626,19 @@ book_returnfolder(Pid, RunnerType) ->
ReturnTerms::boolean(), ReturnTerms::boolean(),
TermRegex :: leveled_codec:regular_expression(). TermRegex :: leveled_codec:regular_expression().
book_indexfold(Pid, Constraint, FoldAccT, Range, TermHandling) -> book_indexfold(Pid, Constraint, FoldAccT, Range, TermHandling)
when is_tuple(Constraint) ->
RunnerType = RunnerType =
{index_query, Constraint, FoldAccT, Range, TermHandling}, {index_query, Constraint, FoldAccT, Range, TermHandling},
book_returnfolder(Pid, RunnerType). book_returnfolder(Pid, RunnerType);
book_indexfold(Pid, Bucket, FoldAccT, Range, TermHandling) ->
% StartKey must be specified to avoid confusion when bucket is a tuple.
% Use an empty StartKey if no StartKey is required (e.g. <<>>). In a
% future release this code branch may be removed, and such queries may
% instead return `error`. For now null is assumed to be lower than any
% key
leveled_log:log("B0019", [Bucket]),
book_indexfold(Pid, {Bucket, null}, FoldAccT, Range, TermHandling).
%% @doc list buckets. Folds over the ledger only. Given a `Tag' folds %% @doc list buckets. Folds over the ledger only. Given a `Tag' folds
@ -2914,5 +2923,4 @@ check_notfound_test() ->
?assertMatch({false, 0}, check_notfound(0, MissingFun)). ?assertMatch({false, 0}, check_notfound(0, MissingFun)).
-endif. -endif.

View file

@ -57,6 +57,9 @@
{"B0018", {"B0018",
{info, "Positive HEAD responses timed with sample_count=~w and " {info, "Positive HEAD responses timed with sample_count=~w and "
++ " pcl_time=~w rsp_time=~w"}}, ++ " pcl_time=~w rsp_time=~w"}},
{"B0019",
{warn, "Use of book_indexfold with constraint of Bucket ~w with "
++ "no StartKey is deprecated"}},
{"R0001", {"R0001",
{debug, "Object fold to process batch of ~w objects"}}, {debug, "Object fold to process batch of ~w objects"}},