Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0227-Add-specs-for-missing-mnesia-functions.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0227-Add-specs-for-missing-mnesia-functions.patch of Package erlang
From d9d0247a45e3afb4c9cf4420438d9e261b32690e Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson <dgud@erlang.org> Date: Wed, 20 Dec 2023 15:50:03 +0100 Subject: [PATCH 1/4] Add specs for missing mnesia functions --- lib/mnesia/src/mnesia_frag_hash.erl | 23 ++++++++++++++++++++--- lib/mnesia/src/mnesia_registry.erl | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/mnesia/src/mnesia_frag_hash.erl b/lib/mnesia/src/mnesia_frag_hash.erl index d658ab2770..52c2eee330 100644 --- a/lib/mnesia/src/mnesia_frag_hash.erl +++ b/lib/mnesia/src/mnesia_frag_hash.erl @@ -47,7 +47,10 @@ function}). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +-spec init_state(Tab, State) -> NewState when + Tab :: atom(), + State :: term(), + NewState :: term(). init_state(_Tab, State) when State == undefined -> #hash_state{n_fragments = 1, next_n_to_split = 1, @@ -62,6 +65,10 @@ convert_old_state({hash_state, N, P, L}) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec add_frag(State :: term()) -> {NewState, IterFrags, AdditionalLockFrags} when + NewState :: term(), + IterFrags :: [integer()], + AdditionalLockFrags :: [integer()]. add_frag(#hash_state{next_n_to_split = SplitN, n_doubles = L, n_fragments = N} = State) -> P = SplitN + 1, NewN = N + 1, @@ -81,6 +88,10 @@ add_frag(OldState) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec del_frag(State :: term()) -> {NewState, IterFrags, AdditionalLockFrags} when + NewState :: term(), + IterFrags :: [integer()], + AdditionalLockFrags :: [integer()]. del_frag(#hash_state{next_n_to_split = SplitN, n_doubles = L, n_fragments = N} = State) -> P = SplitN - 1, if @@ -102,7 +113,10 @@ del_frag(OldState) -> del_frag(State). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +-spec key_to_frag_number(State, Key) -> Fragnum when + State :: term(), + Key :: term(), + Fragnum :: integer(). key_to_frag_number(#hash_state{function = phash, n_fragments = N, n_doubles = L}, Key) -> A = erlang:phash(Key, power2(L + 1)), if @@ -124,7 +138,10 @@ key_to_frag_number(OldState, Key) -> key_to_frag_number(State, Key). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +-spec match_spec_to_frag_numbers(State, MatchSpec) -> Fragnums when + State :: term(), + MatchSpec :: ets:match_spec(), + Fragnums :: [integer()]. match_spec_to_frag_numbers(#hash_state{n_fragments = N} = State, MatchSpec) -> case MatchSpec of [{HeadPat, _, _}] when is_tuple(HeadPat), tuple_size(HeadPat) > 2 -> diff --git a/lib/mnesia/src/mnesia_registry.erl b/lib/mnesia/src/mnesia_registry.erl index 55ddc3d2fd..d829683bfc 100644 --- a/lib/mnesia/src/mnesia_registry.erl +++ b/lib/mnesia/src/mnesia_registry.erl @@ -143,13 +143,14 @@ start_dump(Tab, LinkTo) -> start_restore(Tab, LinkTo) -> start(restore, Tab, LinkTo). - +-spec create_table(Tab :: atom()) -> 'ok'. %% Optionally creates the Mnesia table Tab with suitable default values. %% Returns ok or EXIT's create_table(Tab) -> Storage = mnesia:table_info(schema, storage_type), create_table(Tab, [{Storage, [node()]}]). +-spec create_table(Tab :: atom(), Opt :: [{atom(), term()}]) -> ok. create_table(Tab, TabDef) -> Attrs = record_info(fields, registry_entry), case mnesia:create_table(Tab, [{attributes, Attrs} | TabDef]) of -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor