提交 6739bdfb authored 作者: andrei's avatar andrei

preserve MVStore versions during DEFRAG

上级 061d9cd1
...@@ -1103,8 +1103,19 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1103,8 +1103,19 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* @param sourceMap the source map * @param sourceMap the source map
*/ */
final void copyFrom(MVMap<K, V> sourceMap) { final void copyFrom(MVMap<K, V> sourceMap) {
// We are going to cheat a little bit in the copy()
// by setting map's root to an arbitrary nodes
// to allow for just created ones to be saved.
// That's why it's important to preserve all chunks
// created in the process, especially it retention time
// is set to a lower value, or even 0.
MVStore.TxCounter txCounter = store.registerVersionUsage();
try {
beforeWrite(); beforeWrite();
setRoot(copy(sourceMap.getRootPage())); setRoot(copy(sourceMap.getRootPage()));
} finally {
store.deregisterVersionUsage(txCounter);
}
} }
private Page copy(Page source) { private Page copy(Page source) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论