|
@@ -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)
|