Change key() definition to not allow integer keys

This commit is contained in:
Martin Sumner 2018-09-03 12:28:31 +01:00
parent 402dd2a663
commit c64dc1df0d
2 changed files with 7 additions and 4 deletions

View file

@ -163,6 +163,8 @@
-type timing_types() :: head|get|put|fold. -type timing_types() :: head|get|put|fold.
-type recent_aae() :: false|#recent_aae{}|undefined. -type recent_aae() :: false|#recent_aae{}|undefined.
-type key() :: binary()|string(). -type key() :: binary()|string().
% Keys SHOULD be binary()
% string() support is a legacy of old tests
-type open_options() :: -type open_options() ::
%% For full description of options see ../docs/STARTUP_OPTIONS.md %% For full description of options see ../docs/STARTUP_OPTIONS.md
[{root_path, string()|undefined} | [{root_path, string()|undefined} |
@ -279,6 +281,8 @@
% Defaults to ?COMPRESSION_POINT % Defaults to ?COMPRESSION_POINT
]. ].
-export_type([key/0]).
%%%============================================================================ %%%============================================================================
%%% API %%% API

View file

@ -837,16 +837,15 @@ get_metadata_from_siblings(<<ValLen:32/integer, Rest0/binary>>,
MetaBin:MetaLen/binary>>, MetaBin:MetaLen/binary>>,
[LastMod|LastMods]). [LastMod|LastMods]).
-spec next_key(leveled_bookie:key()) -> leveled_bookie:key().
%% @doc
%% Get the next key to iterate from a given point
next_key(Key) when is_binary(Key) -> next_key(Key) when is_binary(Key) ->
<<Key/binary, 0>>; <<Key/binary, 0>>;
next_key(Key) when is_integer(Key) ->
Key + 1;
next_key(Key) when is_list(Key) -> next_key(Key) when is_list(Key) ->
Key ++ [0]. Key ++ [0].
%%%============================================================================ %%%============================================================================
%%% Test %%% Test
%%%============================================================================ %%%============================================================================