feat(ds): Allow incremental update of the LTS trie

This commit is contained in:
ieQu1 2024-05-07 18:26:59 +02:00
parent 68ca891f41
commit 1ddbbca90e
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
1 changed files with 6 additions and 1 deletions

View File

@ -21,6 +21,7 @@
trie_create/1, trie_create/0, trie_create/1, trie_create/0,
destroy/1, destroy/1,
trie_restore/2, trie_restore/2,
trie_update/2,
trie_copy_learned_paths/2, trie_copy_learned_paths/2,
topic_key/3, topic_key/3,
match_topics/2, match_topics/2,
@ -126,7 +127,11 @@ destroy(#trie{trie = Trie, stats = Stats}) ->
%% @doc Restore trie from a dump %% @doc Restore trie from a dump
-spec trie_restore(options(), [{_Key, _Val}]) -> trie(). -spec trie_restore(options(), [{_Key, _Val}]) -> trie().
trie_restore(Options, Dump) -> trie_restore(Options, Dump) ->
Trie = trie_create(Options), trie_update(trie_create(Options), Dump).
%% @doc Update a trie with a dump of operations (used for replication)
-spec trie_update(trie(), [{_Key, _Val}]) -> trie().
trie_update(Trie, Dump) ->
lists:foreach( lists:foreach(
fun({{StateFrom, Token}, StateTo}) -> fun({{StateFrom, Token}, StateTo}) ->
trie_insert(Trie, StateFrom, Token, StateTo) trie_insert(Trie, StateFrom, Token, StateTo)