Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Lite claims that it can be modified in-place, but I'm curious how that works with variable-length structures like strings?


If the new value is equal size or smaller, it will overwrite the old value in-place. If it is larger, then the new value is appended to the buffer and the index structure is updated to point to the new location.

In the case of append, the old value still lives inside the buffer but is zeroed out. This means that if you keep replacing variable-sized elements, over time the buffer will fragment. You can vacuum a message by recursively writing it from the root to a new buffer. This will clear out the unused space. This operation can be delayed for as long as you like.

If you are only setting fixed-size values like integers or floats, then the buffer never grows as they are always updated in-place.


Interesting. Sounds like you are getting copy-on-write-with-sharing for growing sizes and in-place updates when your data shrinks?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: