microo8 / mimir

Generates minimal embedded database from structs in golang; moved to gitlab.com/microo8/mimir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rand.Int() not the best way for the id.

johnkl opened this issue · comments

  1. Collisions should not be allowed.
  2. ID range may be very large(In my current project I'm not sure that's enough uint64).

I propose to use []byte as an identifier.
You can allow the user to select the number of bytes for the index.
And a choice of two options:

  1. autoincrement (without affecting the user part of mimir)
    something like that:
func inc(b []byte) {
    for j := 0; j < len(b); j++ {
        b[j]++
        if b[j] > 0 {
            break
        }
    }
}
  1. User-defined identifier in operations
    something like that:
    persons.AddWithId([]byte{0,0,0,1}, person)
    Anyway, rand.Int() not the best way for the identifier field in production.

I would expect you to address this issue, because I greatly enjoyed mimir use in my new project.

tiedot uses it and it has +1600 stars :) and I want to have as minimal API as posible, and I don't want from the user to specify the number of bytes for id. I think 2^64 is enough for id. Or maybe I can add some uuid support, before code generation. I'll think about it :)

I'm glad to hear that you already using Mímir in an project :) is it public? Can you show me?

And thanks for contributing so much :)

Sorry, this is a private project.