|
|
@@ -32,7 +32,8 @@
|
|
|
get_streams/4,
|
|
|
make_iterator/5,
|
|
|
update_iterator/4,
|
|
|
- next/4
|
|
|
+ next/4,
|
|
|
+ post_creation_actions/1
|
|
|
]).
|
|
|
|
|
|
%% internal exports:
|
|
|
@@ -200,6 +201,22 @@ open(_Shard, DBHandle, GenId, CFRefs, Schema) ->
|
|
|
ts_offset = TSOffsetBits
|
|
|
}.
|
|
|
|
|
|
+-spec post_creation_actions(emqx_ds_storage_layer:post_creation_context()) ->
|
|
|
+ s().
|
|
|
+post_creation_actions(
|
|
|
+ #{
|
|
|
+ db := DBHandle,
|
|
|
+ old_gen_id := OldGenId,
|
|
|
+ old_cf_refs := OldCFRefs,
|
|
|
+ new_gen_runtime_data := NewGenData0
|
|
|
+ }
|
|
|
+) ->
|
|
|
+ {_, OldTrieCF} = lists:keyfind(trie_cf(OldGenId), 1, OldCFRefs),
|
|
|
+ #s{trie = NewTrie0} = NewGenData0,
|
|
|
+ NewTrie = copy_previous_trie(DBHandle, NewTrie0, OldTrieCF),
|
|
|
+ ?tp(bitfield_lts_inherited_trie, #{}),
|
|
|
+ NewGenData0#s{trie = NewTrie}.
|
|
|
+
|
|
|
-spec drop(
|
|
|
emqx_ds_storage_layer:shard_id(),
|
|
|
rocksdb:db_handle(),
|
|
|
@@ -516,6 +533,17 @@ restore_trie(TopicIndexBytes, DB, CF) ->
|
|
|
rocksdb:iterator_close(IT)
|
|
|
end.
|
|
|
|
|
|
+-spec copy_previous_trie(rocksdb:db_handle(), emqx_ds_lts:trie(), rocksdb:cf_handle()) ->
|
|
|
+ emqx_ds_lts:trie().
|
|
|
+copy_previous_trie(DBHandle, NewTrie, OldCF) ->
|
|
|
+ {ok, IT} = rocksdb:iterator(DBHandle, OldCF, []),
|
|
|
+ try
|
|
|
+ OldDump = read_persisted_trie(IT, rocksdb:iterator_move(IT, first)),
|
|
|
+ emqx_ds_lts:trie_restore_existing(NewTrie, OldDump)
|
|
|
+ after
|
|
|
+ rocksdb:iterator_close(IT)
|
|
|
+ end.
|
|
|
+
|
|
|
read_persisted_trie(IT, {ok, KeyB, ValB}) ->
|
|
|
[
|
|
|
{binary_to_term(KeyB), binary_to_term(ValB)}
|