Skip to content

Commit

Permalink
Dev to main (#49)
Browse files Browse the repository at this point in the history
* fix go mod

* Dev to Main (#39)

* try fixing race

* Revert "try fixing race"

This reverts commit 02ff901.

* using lock for set child and get child

* using locks only for set child and get child

* fix nil mu

* fix delete

* using locks to set attribute of node

* fix memdb tests

* tracking channel of child changes

* removed process lazy redundant

* fix nil check

* Fix get watch bug

* go fmt

* some minor fixes

* merge main

* fix go mod

* fix go mod

* fmt

* Dev to Main (#40)

* try fixing race

* Revert "try fixing race"

This reverts commit 02ff901.

* using lock for set child and get child

* using locks only for set child and get child

* fix nil mu

* fix delete

* using locks to set attribute of node

* fix memdb tests

* tracking channel of child changes

* removed process lazy redundant

* fix nil check

* Fix get watch bug

* go fmt

* some minor fixes

* merge main

* fix go mod

* fix go mod

* some minor fixes

* some minor fixes

* fmt

* Dev to main (#41)

* try fixing race

* Revert "try fixing race"

This reverts commit 02ff901.

* using lock for set child and get child

* using locks only for set child and get child

* fix nil mu

* fix delete

* using locks to set attribute of node

* fix memdb tests

* tracking channel of child changes

* removed process lazy redundant

* fix nil check

* Fix get watch bug

* go fmt

* some minor fixes

* merge main

* fix go mod

* fix go mod

* some minor fixes

* some minor fixes

* fmt

* some fixes

* Dev to Main (#42)

* try fixing race

* Revert "try fixing race"

This reverts commit 02ff901.

* using lock for set child and get child

* using locks only for set child and get child

* fix nil mu

* fix delete

* using locks to set attribute of node

* fix memdb tests

* tracking channel of child changes

* removed process lazy redundant

* fix nil check

* Fix get watch bug

* go fmt

* some minor fixes

* merge main

* fix go mod

* fix go mod

* some minor fixes

* some minor fixes

* fmt

* some fixes

* fix seek prefix watch

* SeekPrefix Watch Fix (#43)

* try fixing race

* Revert "try fixing race"

This reverts commit 02ff901.

* using lock for set child and get child

* using locks only for set child and get child

* fix nil mu

* fix delete

* using locks to set attribute of node

* fix memdb tests

* tracking channel of child changes

* removed process lazy redundant

* fix nil check

* Fix get watch bug

* go fmt

* some minor fixes

* merge main

* fix go mod

* fix go mod

* some minor fixes

* some minor fixes

* fmt

* some fixes

* fix seek prefix watch

* bug fix

* fix bug
  • Loading branch information
absolutelightning authored May 29, 2024
1 parent 8c98e7a commit 350f0b6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,28 +371,33 @@ func (t *Txn[T]) removeChild4(n Node[T], c byte) Node[T] {
n.processLazyRef()

if n.getNumChildren() == 1 {
nodeToReturn := n.getChild(0)
// Is not leaf
if !n.getChildren()[0].isLeaf() && n.getRefCount() == 2 {
newChildZero := n.getChild(0).clone(true, false)
if !n.getChild(0).isLeaf() && n.getRefCount() == 1 {
nodeToReturn = n.getChild(0).clone(true, false)
// Concatenate the prefixes
prefix := int(n.getPartialLen())
if prefix < maxPrefixLen {
n.getPartial()[prefix] = n.getKeyAtIdx(0)
prefix++
}
if prefix < maxPrefixLen {
subPrefix := min(int(newChildZero.getPartialLen()), maxPrefixLen-prefix)
copy(n.getPartial()[prefix:], newChildZero.getPartial()[:subPrefix])
subPrefix := min(int(nodeToReturn.getPartialLen()), maxPrefixLen-prefix)
copy(n.getPartial()[prefix:], nodeToReturn.getPartial()[:subPrefix])
prefix += subPrefix
}

// Store the prefix in the child
copy(newChildZero.getPartial(), n.getPartial()[:min(prefix, maxPrefixLen)])
newChildZero.setPartialLen(newChildZero.getPartialLen() + n.getPartialLen() + 1)
newChildZero.incrementLazyRefCount(1)
copy(nodeToReturn.getPartial(), n.getPartial()[:min(prefix, maxPrefixLen)])
nodeToReturn.setPartialLen(nodeToReturn.getPartialLen() + n.getPartialLen() + 1)
nodeToReturn.incrementLazyRefCount(1)
t.trackChannel(n)
n.incrementLazyRefCount(-1)
return newChildZero
return nodeToReturn
}
if n.getRefCount() == 1 {
n.incrementLazyRefCount(-1)
return nodeToReturn
}
}
return n
Expand Down

0 comments on commit 350f0b6

Please sign in to comment.