-
Notifications
You must be signed in to change notification settings - Fork 60
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
Data file with 0 buckets (header only) just returns "invalid bucket count" #46
Comments
Hmm... an interesting corner case that I have not thought of. The key file has to have one empty bucket upon creation. What do you suggest as a fix? |
I think the idea of having a database file with 0 entries is a valid potential use case. Potential solutions off the top of my head could be a special "Nil" entry for empty databases that can get removed on the first insert (which would hurt the "append-only" paradigm), having a default, static "0-th" entry that can always be queried even on empty databases (kinda like a zero register that always returns zero or /dev/null) or just disallowing that use case and requiring at least one value record to exist. Another solution would be to have an "empty" or "uninitialized" flag in the key file header, but this would make the code more complex elsewhere (since it is not enough to check for >0 buckets). It's just something that came up when I tried to start to test the insert command that I wrote and I suddenly couldn't even do the simplest case of inserting an entry into an empty database. I don't really have strong opinions either way. |
Since NuDB is now 1.0.0, what did you decide for resolving this issue? Empty databases have their use after all and currently either the spec or the code is wrong in dealing with this. |
Looks like this is something that needs to be fixed in a future version! |
According to the README "The Data File contains the Header followed by zero or more variable-length Value Records and Spill Records."
However when I manually build a header file, run rekey (with a count of 0) and then verify, verify doesn't like the result at all.
The text was updated successfully, but these errors were encountered: