Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to Main #23

Merged
merged 10 commits into from
May 25, 2024
2 changes: 0 additions & 2 deletions helpers.go
Original file line number Diff line number Diff line change
@@ -346,10 +346,8 @@ func (t *Txn[T]) removeChild4(n *Node4[T], c byte) Node[T] {
if n.numChildren == 1 {
// Is not leaf
if t.trackMutate {
t.tree.idg.delChns[n.children[0].getOldMutateCh()] = struct{}{}
t.tree.idg.delChns[n.children[0].getMutateCh()] = struct{}{}
t.tree.idg.delChns[n.getMutateCh()] = struct{}{}
t.tree.idg.delChns[n.getOldMutateCh()] = struct{}{}
}
newChildZero := n.children[0].clone(false, false)
if !n.children[0].isLeaf() {
9 changes: 6 additions & 3 deletions iterator.go
Original file line number Diff line number Diff line change
@@ -144,10 +144,11 @@ func (i *Iterator[T]) SeekPrefixWatch(prefixKey []byte) (watch <-chan struct{})
return watch
}

i.stack = []Node[T]{node}
i.node = node

for {
// Check if the node matches the prefix
i.stack = []Node[T]{node}
i.node = node
watch = node.getMutateCh()

if node.isLeaf() {
@@ -160,7 +161,6 @@ func (i *Iterator[T]) SeekPrefixWatch(prefixKey []byte) (watch <-chan struct{})
mismatchIdx := prefixMismatch[T](node, prefix, len(prefix), depth)
if mismatchIdx < int(node.getPartialLen()) {
// If there's a mismatch, set the node to nil to break the loop
node = nil
break
}
depth += int(node.getPartialLen())
@@ -180,6 +180,9 @@ func (i *Iterator[T]) SeekPrefixWatch(prefixKey []byte) (watch <-chan struct{})
break
}

i.stack = []Node[T]{node}
i.node = node

// Move to the next level in the tree
node = child
depth++
2 changes: 0 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
@@ -33,8 +33,6 @@ type Node[T any] interface {
getKeys() []byte
getMutateCh() chan struct{}
setMutateCh(chan struct{})
getOldMutateCh() chan struct{}
setOldMutateCh(chan struct{})
getLowerBoundCh(byte) int

Iterator() *Iterator[T]
9 changes: 0 additions & 9 deletions node_16.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ type Node16[T any] struct {
keys [16]byte
children [16]Node[T]
mutateCh chan struct{}
oldMutateCh chan struct{}
refCount int32
}

@@ -211,11 +210,3 @@ func (n *Node16[T]) createNewMutateChn() chan struct{} {
n.setMutateCh(make(chan struct{}))
return n.getMutateCh()
}

func (n *Node16[T]) getOldMutateCh() chan struct{} {
return n.oldMutateCh
}

func (n *Node16[T]) setOldMutateCh(ch chan struct{}) {
n.oldMutateCh = ch
}
9 changes: 0 additions & 9 deletions node_256.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ type Node256[T any] struct {
children [256]Node[T]
mutateCh chan struct{}
refCount int32
oldMutateCh chan struct{}
}

func (n *Node256[T]) getId() uint64 {
@@ -203,11 +202,3 @@ func (n *Node256[T]) createNewMutateChn() chan struct{} {
n.setMutateCh(make(chan struct{}))
return n.getMutateCh()
}

func (n *Node256[T]) getOldMutateCh() chan struct{} {
return n.oldMutateCh
}

func (n *Node256[T]) setOldMutateCh(ch chan struct{}) {
n.oldMutateCh = ch
}
9 changes: 0 additions & 9 deletions node_4.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ type Node4[T any] struct {
children [4]Node[T]
mutateCh chan struct{}
refCount int32
oldMutateCh chan struct{}
}

func (n *Node4[T]) getId() uint64 {
@@ -211,11 +210,3 @@ func (n *Node4[T]) createNewMutateChn() chan struct{} {
n.setMutateCh(make(chan struct{}))
return n.getMutateCh()
}

func (n *Node4[T]) getOldMutateCh() chan struct{} {
return n.oldMutateCh
}

func (n *Node4[T]) setOldMutateCh(ch chan struct{}) {
n.oldMutateCh = ch
}
9 changes: 0 additions & 9 deletions node_48.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ type Node48[T any] struct {
children [48]Node[T]
refCount int32
mutateCh chan struct{}
oldMutateCh chan struct{}
}

func (n *Node48[T]) getId() uint64 {
@@ -215,11 +214,3 @@ func (n *Node48[T]) createNewMutateChn() chan struct{} {
n.setMutateCh(make(chan struct{}))
return n.getMutateCh()
}

func (n *Node48[T]) getOldMutateCh() chan struct{} {
return n.oldMutateCh
}

func (n *Node48[T]) setOldMutateCh(ch chan struct{}) {
n.oldMutateCh = ch
}
19 changes: 5 additions & 14 deletions node_leaf.go
Original file line number Diff line number Diff line change
@@ -9,12 +9,11 @@ import (
)

type NodeLeaf[T any] struct {
id uint64
value T
key []byte
mutateCh chan struct{}
refCount int32
oldMutateCh chan struct{}
id uint64
value T
key []byte
mutateCh chan struct{}
refCount int32
}

func (n *NodeLeaf[T]) getId() uint64 {
@@ -197,11 +196,3 @@ func (n *NodeLeaf[T]) createNewMutateChn() chan struct{} {
n.setMutateCh(make(chan struct{}))
return n.getMutateCh()
}

func (n *NodeLeaf[T]) getOldMutateCh() chan struct{} {
return n.oldMutateCh
}

func (n *NodeLeaf[T]) setOldMutateCh(ch chan struct{}) {
n.oldMutateCh = ch
}
Loading