LibraDB
LibraDB copied to clipboard
Find does not work as expected when a large number of keys is stored.
package main
import (
"fmt"
"strconv"
"github.com/amit-davidson/LibraDB"
)
func main() {
path := "libra.db"
db, _ := LibraDB.Open(path, LibraDB.DefaultOptions)
tx := db.WriteTx()
name := []byte("test")
collection, _ := tx.CreateCollection(name)
for i := 0; i < 100000; i++ {
key := "myKey" + strconv.Itoa(i)
_ = collection.Put([]byte(key), []byte("data"))
}
for i := 0; i < 100000; i++ {
key := "myKey" + strconv.Itoa(i)
item, _ := collection.Find([]byte(key))
fmt.Printf("ite: %v\n", item)
}
_ = tx.Commit()
}
Hi Amit, I thoroughly enjoyed your blog and code 🤟 . I was testing this piece with the above code and it doesn't work as expected. Let me know if I am missing anything.
I'm happy to hear you loved the blog and the code :) @kevinjad Thank you for catching this bug. It's probably somewhere in the B-tree, as something similar was mentioned here: https://github.com/amit-davidson/btree/issues/1. I don't plan to fix the bug, but let me know if you want to open a PR for this.