mr-karan/barreldb

I absolutely love this project

Closed this issue · 3 comments

I bumped into this project by accident. I didn't know how to get in touch :)
It's been a while since I came across such a simple and concise project. I have some use cases that come to mind, just testing for now.
Do you plan to maintain this or it's just a house project?

Cheers!

Thanks for the appreciation!

While, this was a project that I implemented purely as a learning exercise, I've tried my best to add multiple test case scenarios and did manual integration tests. As with any software, this won't be bug free so I am open to fixing any bugs you may encounter.

However, I won't like to extend the API or add any new features (unless there's a very strong reason to do so) as it's fully compatible with the original paper this idea is derived from.

The API looks good and I don't think will need extra features.

I was just testing and for this given snippet

barrel, _ := barrel.Init(barrel.WithDir("data/"))
	
for i := 0; i < 500; i++ {
  id := strconv.Itoa(i)
  barrel.Put("test"+id, []byte("world-"+id))
}

keys := barrel.List()
for i, k := range keys {
  lo.Printf("key %d is %s\n", i, k)
}

I get this error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4d5724]

goroutine 1 [running]:
github.com/mr-karan/barreldb.(*Barrel).Put(0x0, {0xc000018348, 0x5}, {0xc000018340, 0x7, 0x8})
	/home/user/go/pkg/mod/github.com/mr-karan/barreldb@v1.0.0/barrel.go:187 +0x84
main.main()
	/home/user/tests/bareldb/main.go:21 +0x14a
exit status 2
  1. If the db file does not exist everything goes fine.
  2. If I repeat the execution I get the error above

barrel, _ := barrel.Init(barrel.WithDir("data/"))

You shouldn't ignore errors with _. Can you modify the snippet to handle the error and check what is the error message about? The nil pointer is most likely because barrel isn't initialized and is a nil pointer.