-
Notifications
You must be signed in to change notification settings - Fork 373
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
feat: B-Tree added #2677
base: master
Are you sure you want to change the base?
feat: B-Tree added #2677
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2677 +/- ##
==========================================
+ Coverage 63.08% 63.12% +0.04%
==========================================
Files 563 563
Lines 79254 79362 +108
==========================================
+ Hits 49998 50099 +101
- Misses 25896 25905 +9
+ Partials 3360 3358 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Is there something I could do to help with the merging of this PR, @thehowl , @ajnavarro @leohhhn ? (Thank you in advance!) |
Co-authored-by: Antonio Navarro Perez <[email protected]>
Co-authored-by: Antonio Navarro Perez <[email protected]>
Updated test to adapt to new error message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in the implementation, likely in the delete/fill/merge handling.
If you insert a large number of entries into the tree, and then start deleting them, you will run into a situation where you get a .: test pkg: panic: slice index out of bounds: 3 (len=3)
type error.
This is likely related to the recursion near the bottom of the delete function, but there is interplay with the fill/merge functionality. Something is just not quite right, and while it's possible to fix the slice out of bounds, when one does that, after doing a number of deletes, one starts to get keys that are no longer reachable.
This is an incomplete test, but it serves to illustrate the problem:
func TestStress(t *testing.T) {
tree, _ := NewBTree(4)
for j := 0; j < 1000; j++ {
tree.Insert(Content{Key: j, Value: j})
}
if tree.GetSize() != 1000 {
t.Errorf("Expected size of 1000; got %d\n", tree.GetSize())
}
for j := 0; j < 1000; j++ {
found, err := tree.Search(j)
if found.Key != j {
t.Errorf("Search for %d expected to find %d, but got %d\n", j, j, found.Key)
}
}
for j := 0; j < 1000; j += 2 {
tree.Delete(j)
}
}
This still breaks when subjected to the stress test above:
|
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the descriptionAdded B-Tree structure so data can be mantained ordered without using too much operations.