From e69b528f0863a2762dc7a307aa488622c1bfe819 Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut <134911583+absolutelightning@users.noreply.github.com> Date: Thu, 30 May 2024 21:37:57 +0530 Subject: [PATCH] Absl (#54) * fix go mod * Dev to Main (#39) * try fixing race * Revert "try fixing race" This reverts commit 02ff901eaa1f51d4c484e1377f4487c779fdc346. * 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 02ff901eaa1f51d4c484e1377f4487c779fdc346. * 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 02ff901eaa1f51d4c484e1377f4487c779fdc346. * 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 02ff901eaa1f51d4c484e1377f4487c779fdc346. * 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 02ff901eaa1f51d4c484e1377f4487c779fdc346. * 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 * some fixes * track mutation fixes * fix iterator * fix itertor --- iterator.go | 8 ++++---- path_iter.go | 8 ++++---- reverse_iterator.go | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/iterator.go b/iterator.go index fe8e12c..b8ef6b5 100644 --- a/iterator.go +++ b/iterator.go @@ -69,7 +69,7 @@ func (i *Iterator[T]) Next() ([]byte, T, bool) { return getKey(leafCh.key), leafCh.value, true case node4: n4 := currentNode.(*Node4[T]) - for itr := 3; itr >= 0; itr-- { + for itr := int(n4.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n4.children[itr] if nodeCh == nil { continue @@ -82,7 +82,7 @@ func (i *Iterator[T]) Next() ([]byte, T, bool) { } case node16: n16 := currentNode.(*Node16[T]) - for itr := 15; itr >= 0; itr-- { + for itr := int(n16.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n16.children[itr] if nodeCh == nil { continue @@ -95,7 +95,7 @@ func (i *Iterator[T]) Next() ([]byte, T, bool) { } case node48: n48 := currentNode.(*Node48[T]) - for itr := 0; itr < 256; itr++ { + for itr := 0; itr < int(n48.getNumChildren()-1); itr++ { idx := n48.keys[itr] if idx == 0 { continue @@ -112,7 +112,7 @@ func (i *Iterator[T]) Next() ([]byte, T, bool) { } case node256: n256 := currentNode.(*Node256[T]) - for itr := 255; itr >= 0; itr-- { + for itr := int(n256.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n256.children[itr] if nodeCh == nil { continue diff --git a/path_iter.go b/path_iter.go index 605e382..06b3b5c 100644 --- a/path_iter.go +++ b/path_iter.go @@ -43,7 +43,7 @@ func (i *PathIterator[T]) Next() ([]byte, T, bool) { continue case node4: n4 := currentNode.(*Node4[T]) - for itr := 3; itr >= 0; itr-- { + for itr := int(n4.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n4.children[itr] if nodeCh == nil { continue @@ -56,7 +56,7 @@ func (i *PathIterator[T]) Next() ([]byte, T, bool) { } case node16: n16 := currentNode.(*Node16[T]) - for itr := 15; itr >= 0; itr-- { + for itr := int(n16.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n16.children[itr] if nodeCh == nil { continue @@ -69,7 +69,7 @@ func (i *PathIterator[T]) Next() ([]byte, T, bool) { } case node48: n48 := currentNode.(*Node48[T]) - for itr := 255; itr >= 0; itr-- { + for itr := int(n48.getNumChildren() - 1); itr >= 0; itr-- { idx := n48.keys[itr] if idx == 0 { continue @@ -86,7 +86,7 @@ func (i *PathIterator[T]) Next() ([]byte, T, bool) { } case node256: n256 := currentNode.(*Node256[T]) - for itr := 255; itr >= 0; itr-- { + for itr := int(n256.getNumChildren() - 1); itr >= 0; itr-- { nodeCh := n256.children[itr] if nodeCh == nil { continue diff --git a/reverse_iterator.go b/reverse_iterator.go index b8f6fb2..37de4bf 100644 --- a/reverse_iterator.go +++ b/reverse_iterator.go @@ -216,7 +216,7 @@ func (ri *ReverseIterator[T]) Previous() ([]byte, T, bool) { return getKey(leafCh.key), leafCh.value, true case node4: n4 := currentNode.(*Node4[T]) - for itr := 0; itr < 4; itr++ { + for itr := 0; itr < int(n4.getNumChildren()); itr++ { nodeCh := n4.children[itr] if nodeCh == nil { continue @@ -229,7 +229,7 @@ func (ri *ReverseIterator[T]) Previous() ([]byte, T, bool) { } case node16: n16 := currentNode.(*Node16[T]) - for itr := 0; itr < 16; itr++ { + for itr := 0; itr < int(n16.getNumChildren()); itr++ { nodeCh := n16.children[itr] if nodeCh == nil { continue @@ -242,7 +242,7 @@ func (ri *ReverseIterator[T]) Previous() ([]byte, T, bool) { } case node48: n48 := currentNode.(*Node48[T]) - for itr := 0; itr < 256; itr++ { + for itr := 0; itr < int(n48.getNumChildren()); itr++ { idx := n48.keys[itr] if idx == 0 { continue @@ -259,7 +259,7 @@ func (ri *ReverseIterator[T]) Previous() ([]byte, T, bool) { } case node256: n256 := currentNode.(*Node256[T]) - for itr := 0; itr < 256; itr++ { + for itr := 0; itr < int(n256.getNumChildren()); itr++ { nodeCh := n256.children[itr] if nodeCh == nil { continue