-
Notifications
You must be signed in to change notification settings - Fork 9
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
How about mmapping these bad boys? #2
Comments
My first thought is: can an Is it enough? Is there a need for explicit support in |
The only issue I envision is that one may want to use an mmap allocator sometimes but not always (e.g. contingent on an input argument). I think the allocator approach could work as long as |
The allocator is a template parameter. Isn't it sufficient to do something like: template<typename IDX, unsigned BITS = 0, typename W = uint64_t>
using ts_vector = compact_vector::ts_vector<IDX, BITS, W, std::pmr::polymorphic_allocator<W>>; Now you can use I'll admit I have not used polymorphic allocators yet. I would be curious how easy or difficult to write such an allocator. |
Having a way to serialize the data structures (just get a few pointers with offsets a few widths) and a constructor that takes the same data structures would be already of great value for our research database. By skipping over the code, I haven't seen anything that would rule such methods out. |
There are really two classes. A compact iterator that does all the actual work. All it cares about is having a based pointer and the length of elements in bits. It really does not care where the memory comes from (allocated by the vector class or directly with malloc or mmap). The vector class does very little: it allocates memory using the allocator template parameter, and otherwise delegates everything to the iterator. There are a few non-standard calls: The vector class can't be recreated directly from these elements unfortunately, although it could be done with an allocator. And probably it is best if done within an allocator as otherwise methods that resize the vector may use the wrong type of allocator to manage the pointer. |
Argh, yes. We are are using the vectors read-only. Never thought about growing. |
Hi again, @gmarcais!
Another random question / feature request. Imagine that I want to use a
compact_vector
to store a very large array of encoded integers (e.g. a large suffix array or such). Now, I'm going to compute this array at great cost once, and then use it many times. If the vector is sufficiently large, one spends a lot of time deserializing it into RAM. However, since the layout is so nice, it might make sense to justmmap
it so that we can start using it immediately. What do you think it the best way to do this withcompact_vector
?The text was updated successfully, but these errors were encountered: