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

Find does not work as expected when a large number of keys is stored. #1

Open
kevinjad opened this issue Dec 20, 2023 · 1 comment
Open

Comments

@kevinjad
Copy link

kevinjad commented Dec 20, 2023

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.

@amit-davidson
Copy link
Owner

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: amit-davidson/btree#1. I don't plan to fix the bug, but let me know if you want to open a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants