Closed ghost closed 8 years ago
@deuter0n
Overhelming :-(
If you would like to volunteer and send me bite sized PRs to incrementally fix the non-cosmetic items, I would be more than happy to review, test and merge them when ok.
:) Don't worry I didn't expect anything.
I'm considering using this db for my project, I like it because I can hook block encryption in OSFiler. Added some PR #4 #5 #6 #7 #8 #9 #10 #11 .
Some questions:
for _, i := range rand.Perm(1<<20) {
k := make([]byte, 4)
binary.BigEndian.PutUint32(k, uint32(i))
if e = btree.Set(k, nil); e != nil {
log.Fatal(e)
}
}
Added some PR #4 #5 #6 #7 #8 #9 #10 #11 .
Wow! Thank you very much. This will need some time, hopefully this weekend...
what's the intended usage of IndexSeek()
IndexSeek
is like Seek
but it can use a different comparator/collating function than the one used when the Btree
was created. It's not yet used by none of my projects ATM, but IIRC, it's intended use is for seeking in compound indexes (by ql
).
does it need vacuum ?
I would say no, but the client code must manually deallocate anything unused/unreachable otherwise the storage will leak space. However, if there is free space in the middle of a lldb
DB and anything still allocated after that free space, the DB cannot shrink because the Allocator
handles are always stable.
So the more precise answer is that any free space at the end of the DB is automatically freed, while any free space in the middle of a DB is hopefully eventually allocated again when the ratio of inserts to deletes gets positive again. Admittedly, that may never happen after some initial burst.
To rearrange allocated objects such that no free space is left in the middle of the DB is not directly feasible by lldb
itself as it has no knowledge about any references between those objects and which would have to be updated when performing such "compacting GC". However, it would be possible to implement such generic STW collector if it is passed
and there's enough free disk space to switch to the new (out-of-place) DB.
Only now seeing the edited post with the added question, will look into it too.
Unfortunately, GitHub does not send any notifications when a post is edited and I replied to the original one only. I suggest to simply add a new message in this cases.
All PRs merged, BTree issue tracked separately in #12. Closing, but please feel free to let me know if there's some oversight. Thank you.
Running
gometalinter --deadline=10s "./..."
produces the following output. Some are cosmetics, but unchecked errors, shadowed vars might be hiding bugs.