google / btree

BTree provides a simple, ordered, in-memory data structure for Go programs.
Apache License 2.0
3.9k stars 414 forks source link

What is the meaning of `copyOnWriteContext`? #38

Closed dahaihu closed 3 years ago

dahaihu commented 3 years ago

What is the meaning of copyOnWriteContext ?
Only when tree is created, the only one copyOnWriteContext is initiated. There is no other time that create a newcopyOnWriteContext.
In function mutableFor, the n.cow always equals cow.

dahaihu commented 3 years ago

I found the use of copyOnWriteContext. When a tree is cloned, the unmodified node shares the same view of tree with the original tree.