HouzuoGuo / tiedot

A rudimentary implementation of a basic document (NoSQL) database in Go
BSD 2-Clause "Simplified" License
2.72k stars 258 forks source link

Incremented record ID #173

Open dipakw opened 4 years ago

dipakw commented 4 years ago

HouzuoGuo,

By incremented IDs, I mean ID 1 for first record, 2 for second record, 3 for third and so forth.

I am pretty interested in tiedot, played around it, I find it suitable for my project. One thing I am pretty annoyed of, is, it uses generated IDs. I looked into code and found that rand.Int() is used to generate new ID.

To me, it would be awesome if there won't be any issues with incremented IDs. I tried modifying Insert function little to achieve that, and achieved.

My question is that, are there any potential issues that will occur doing so?

HouzuoGuo commented 4 years ago

Thanks for your interest in this project @dipakw. That's a good suggestion, in fact I wish I had used that approach to begin with.

dipakw commented 4 years ago

I appreciate your immediate response, HouzuoGuo. If I get extra hours to do it properly, and think like good to propagate to others as well, you might get pull request in the future.

HouzuoGuo commented 4 years ago

many thanks for your contribution @dipakw !

adiroiban commented 4 years ago

I think that rand.int() can also end up with a high probability of a conflict... so an UUID can help for unique / unpredictable ID.