Tidy up some undefined functions in dialyzer specs (#368)

This commit is contained in:
Martin Sumner 2021-11-05 09:15:25 +00:00
parent f5ba2fc1b9
commit 82cc76c8c6
4 changed files with 33 additions and 16 deletions

View file

@ -638,7 +638,7 @@ book_sqn(Pid, Bucket, Key) ->
book_sqn(Pid, Bucket, Key, Tag) -> book_sqn(Pid, Bucket, Key, Tag) ->
gen_server:call(Pid, {head, Bucket, Key, Tag, true}, infinity). gen_server:call(Pid, {head, Bucket, Key, Tag, true}, infinity).
-spec book_returnfolder(pid(), tuple()) -> {async, fun()}. -spec book_returnfolder(pid(), tuple()) -> {async, fun(() -> term())}.
%% @doc Folds over store - deprecated %% @doc Folds over store - deprecated
%% The tuple() is a query, and book_returnfolder will return an {async, Folder} %% The tuple() is a query, and book_returnfolder will return an {async, Folder}
@ -710,7 +710,7 @@ book_returnfolder(Pid, RunnerType) ->
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(() -> term())}
when Bucket::term(), when Bucket::term(),
StartKey::term(), StartKey::term(),
FoldFun::fun((Bucket, Key | {IndexVal, Key}, Acc) -> Acc), FoldFun::fun((Bucket, Key | {IndexVal, Key}, Acc) -> Acc),
@ -1120,7 +1120,7 @@ book_destroy(Pid) ->
gen_server:call(Pid, destroy, infinity). gen_server:call(Pid, destroy, infinity).
-spec book_hotbackup(pid()) -> {async, fun()}. -spec book_hotbackup(pid()) -> {async, fun(() -> ok)}.
%% @doc Backup the Bookie %% @doc Backup the Bookie
%% Return a function that will take a backup of a snapshot of the Journal. %% Return a function that will take a backup of a snapshot of the Journal.
%% The function will be 1-arity, and can be passed the absolute folder name %% The function will be 1-arity, and can be passed the absolute folder name
@ -1808,7 +1808,8 @@ set_options(Opts) ->
-spec return_snapfun(book_state(), store|ledger, -spec return_snapfun(book_state(), store|ledger,
tuple()|no_lookup|undefined, tuple()|no_lookup|undefined,
boolean(), boolean()) -> fun(). boolean(), boolean())
-> fun(() -> {ok, pid(), pid()|null}).
%% @doc %% @doc
%% Generates a function from which a snapshot can be created. The primary %% Generates a function from which a snapshot can be created. The primary
%% factor here is the SnapPreFold boolean. If this is true then the snapshot %% factor here is the SnapPreFold boolean. If this is true then the snapshot
@ -1845,7 +1846,7 @@ snaptype_by_presence(true) ->
snaptype_by_presence(false) -> snaptype_by_presence(false) ->
ledger. ledger.
-spec get_runner(book_state(), tuple()) -> {async, fun()}. -spec get_runner(book_state(), tuple()) -> {async, fun(() -> term())}.
%% @doc %% @doc
%% Get an {async, Runner} for a given fold type. Fold types have different %% Get an {async, Runner} for a given fold type. Fold types have different
%% tuple inputs %% tuple inputs
@ -1972,7 +1973,8 @@ get_runner(State, DeprecatedQuery) ->
get_deprecatedrunner(State, DeprecatedQuery). get_deprecatedrunner(State, DeprecatedQuery).
-spec get_deprecatedrunner(book_state(), tuple()) -> {async, fun()}. -spec get_deprecatedrunner(book_state(), tuple()) ->
{async, fun(() -> term())}.
%% @doc %% @doc
%% Get an {async, Runner} for a given fold type. Fold types have different %% Get an {async, Runner} for a given fold type. Fold types have different
%% tuple inputs. These folds are currently used in tests, but are deprecated. %% tuple inputs. These folds are currently used in tests, but are deprecated.

View file

@ -175,7 +175,7 @@
fun((any(), binary(), integer(), any(), fun((binary()) -> any())) -> fun((any(), binary(), integer(), any(), fun((binary()) -> any())) ->
{stop|loop, any()}). {stop|loop, any()}).
-export_type([filter_fun/0]).
%%%============================================================================ %%%============================================================================
%%% API %%% API
@ -1386,8 +1386,8 @@ startup_filter(Key, _ValueAsBin, Position, {Hashtree, _LastKey}, _ExtractFun) ->
{loop, {put_hashtree(Key, Position, Hashtree), Key}}. {loop, {put_hashtree(Key, Position, Hashtree), Key}}.
-spec scan_over_file(file:io_device(), file_location(), fun(), any(), any()) -spec scan_over_file(file:io_device(), file_location(),
-> {file_location(), any()}. filter_fun(), any(), any()) -> {file_location(), any()}.
%% Scan for key changes - scan over file returning applying FilterFun %% Scan for key changes - scan over file returning applying FilterFun
%% The FilterFun should accept as input: %% The FilterFun should accept as input:
%% - Key, ValueBin, Position, Accumulator, Fun (to extract values from Binary) %% - Key, ValueBin, Position, Accumulator, Fun (to extract values from Binary)
@ -1500,8 +1500,11 @@ safe_read_next_value(Handle, Length, KeyBin) ->
ReadFun = fun(VBin) -> crccheck(VBin, KeyBin) end, ReadFun = fun(VBin) -> crccheck(VBin, KeyBin) end,
safe_read_next(Handle, Length, ReadFun). safe_read_next(Handle, Length, ReadFun).
-type read_output() :: {term(), binary()}|binary()|term()|false.
-type read_fun() :: fun((binary()) -> read_output()).
-spec safe_read_next(file:io_device(), integer(), fun()) -> any(). -spec safe_read_next(file:io_device(), integer(), read_fun())
-> read_output().
%% @doc %% @doc
%% Read the next item of length Length %% Read the next item of length Length
%% Previously catching error:badarg was sufficient to capture errors of %% Previously catching error:badarg was sufficient to capture errors of
@ -1515,7 +1518,7 @@ safe_read_next(Handle, Length, ReadFun) ->
false false
end. end.
-spec loose_read(file:io_device(), integer(), fun()) -> any(). -spec loose_read(file:io_device(), integer(), read_fun()) -> read_output().
%% @doc %% @doc
%% Read with minimal error handling (only eof) - to be wrapped in %% Read with minimal error handling (only eof) - to be wrapped in
%% safe_read_next/3 to catch exceptions. %% safe_read_next/3 to catch exceptions.

View file

@ -290,7 +290,12 @@ ink_close(Pid) ->
ink_doom(Pid) -> ink_doom(Pid) ->
gen_server:call(Pid, doom, infinity). gen_server:call(Pid, doom, infinity).
-spec ink_fold(pid(), integer(), {fun(), fun(), fun()}, any()) -> fun(). -spec ink_fold(pid(),
integer(),
{leveled_cdb:filter_fun(),
fun((string(), leveled_codec:sqn()) -> term()),
fun((term(), term()) -> term())},
term()) -> fun(() -> term()).
%% @doc %% @doc
%% Fold over the journal from a starting sequence number (MinSQN), passing %% Fold over the journal from a starting sequence number (MinSQN), passing
%% in three functions and a snapshot of the penciller. The Fold functions %% in three functions and a snapshot of the penciller. The Fold functions
@ -773,6 +778,7 @@ handle_cast({remove_logs, ForcedLogs}, State) ->
CDBopts0 = CDBopts#cdb_options{log_options = leveled_log:get_opts()}, CDBopts0 = CDBopts#cdb_options{log_options = leveled_log:get_opts()},
{noreply, State#state{cdb_options = CDBopts0}}. {noreply, State#state{cdb_options = CDBopts0}}.
%% handle the bookie stopping and stop this snapshot %% handle the bookie stopping and stop this snapshot
handle_info({'DOWN', BookieMonRef, process, _BookiePid, _Info}, handle_info({'DOWN', BookieMonRef, process, _BookiePid, _Info},
State=#state{bookie_monref = BookieMonRef}) -> State=#state{bookie_monref = BookieMonRef}) ->

View file

@ -1957,7 +1957,13 @@ pointer_mapfun(Pointer) ->
SK, SK,
EK}. EK}.
-spec binarysplit_mapfun(binary(), integer()) -> fun().
-type slotbin_fun() ::
fun(({non_neg_integer(), non_neg_integer(), non_neg_integer(),
range_endpoint(), range_endpoint()}) ->
{binary(), non_neg_integer(), range_endpoint(), range_endpoint()}).
-spec binarysplit_mapfun(binary(), integer()) -> slotbin_fun().
%% @doc %% @doc
%% Return a function that can pull individual slot binaries from a binary %% Return a function that can pull individual slot binaries from a binary
%% covering multiple slots %% covering multiple slots