fix(ds): bitfield_lts: static_key_size -> static_key_bits

This commit is contained in:
ieQu1 2024-07-01 01:11:40 +02:00
parent f84fb34692
commit 843973ef32
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
2 changed files with 6 additions and 2 deletions

View File

@ -416,7 +416,11 @@ get_id_for_key(#trie{is_binary_key = IsBin, static_key_size = Size}, State, Toke
Hash = crypto:hash(sha256, term_to_binary([State | Token])), Hash = crypto:hash(sha256, term_to_binary([State | Token])),
case IsBin of case IsBin of
false -> false ->
<<Int:(Size * 8), _/bytes>> = Hash, %% Note: for backward compatibility with bitstream_lts
%% layout we allow the key to be an integer. But this also
%% changes the semantics of `static_key_size` from number
%% of bytes to bits:
<<Int:Size, _/bytes>> = Hash,
Int; Int;
true -> true ->
element(1, erlang:split_binary(Hash, Size)) element(1, erlang:split_binary(Hash, Size))

View File

@ -905,7 +905,7 @@ restore_trie(TopicIndexBytes, DB, CF) ->
{ok, IT} = rocksdb:iterator(DB, CF, []), {ok, IT} = rocksdb:iterator(DB, CF, []),
try try
Dump = read_persisted_trie(IT, rocksdb:iterator_move(IT, first)), Dump = read_persisted_trie(IT, rocksdb:iterator_move(IT, first)),
TrieOpts = #{persist_callback => PersistCallback, static_key_size => TopicIndexBytes}, TrieOpts = #{persist_callback => PersistCallback, static_key_bits => TopicIndexBytes * 8},
emqx_ds_lts:trie_restore(TrieOpts, Dump) emqx_ds_lts:trie_restore(TrieOpts, Dump)
after after
rocksdb:iterator_close(IT) rocksdb:iterator_close(IT)