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

Add support for more data structures #7

Closed
luisguve opened this issue Jan 5, 2020 · 3 comments
Closed

Add support for more data structures #7

luisguve opened this issue Jan 5, 2020 · 3 comments
Labels

Comments

@luisguve
Copy link
Contributor

luisguve commented Jan 5, 2020

I really like the idea of storing data in Bolt's b+tree with a slightly different behaviour and API. I think that was your initial goal with simpebolt, along with providing an easy to use API to interact with bbolt.

I would like to collaborate on expanding the available data structures, starting with a doubly linked list like the one at the stdlib.

Although I like the way the data units are related one another, I find it hard to think of a real world example in which an in-memory data structure such as the doubly linked list would be really useful. It's somewhat easier to think of a real world use case of data structures if they're persisted on some sort of database.

I actually have already implemented a doubly linked list, as you can see in my fork of your repo: https://github.com/villegasl/simplebolt/blob/master/linkedlist/linkedlist.go.

I took another approach regarding the organization of the data structures: instead of having the definition of every data structure in a single package, I found it better to encapsulate them in different packages, in this case, package linkedlist. That way, if you want to create a new linkedlist, you'd call: linkedlist.New(db, "my_ll") instead of simplebolt.NewLinkedList(db, "my_ll). I also made a few different decisions about the interface design. I can talk about every change and feature I added so far in a pull request if you are agree.

It is ready to be merged from a pull request, but before I create a PR, I'd like to ask you a couple questions:

  1. Have you already used this library in production, or do you know of some project that's using it?

  2. What are your expectations about the scope of this library? or more specifically, can you think of a real-world application example, say, in a web application?

I would love to help and learn along the way.

@xyproto
Copy link
Owner

xyproto commented Jan 5, 2020

Hi, thanks for the request!

I am in favor of adding another data structure to simplebolt. Just briefly looking through your code, I think it looks good.

When it comes to adding the code in a separate package, I agree with the advantage of typing linkedlist.New instead of simplebolt.NewLinkedList, but for both cases you end up with a variable that will be used further in the program (like myList.DoSomething()), so the increase of verbosity might not have a large impact. I guess both ways have their pros & cons, so I have no strong opinions on this. 🙂

To answer your questions:

  1. I know at least one company uses Algernon internally, which uses BoltDB by default. Other than that, I'm not aware of any. I would be interested to know the answer to this, though.
  2. My goal is that it should be the easiest and fastest way to use BoltDB from Go, both in terms of performance and in ease-of-use, but not in terms of feature richness. I want to keep it simple, easy focused and fast. I would happily welcome and support a fork or a competing project that was more about feature completeness and a large selection of data structures.

If you have further plans for additional data structures, having a more feature rich package (perhaps based on simplebolt) could be a nice idea. If not, I would happily accept the proposed changes to simplebolt.

Best regards,
Alexander F. Rødseth

@xyproto
Copy link
Owner

xyproto commented Mar 24, 2020

I looked at this again today, and merged in your branch. Thanks!

@xyproto xyproto closed this as completed Mar 24, 2020
@xyproto
Copy link
Owner

xyproto commented Mar 24, 2020

The cyclomatic complexity is a bit high: https://goreportcard.com/report/github.com/xyproto/simplebolt

Other than that, the merge looks good and all tests pass.

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

No branches or pull requests

2 participants