store: introduce Database::get_with_rc_stripped method #7483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add get_with_rc_stripped method to the Database trait which strips the
reference count from the returned value.
Previously, Store::get method called get_raw_bytes and then (for
reference counted columns) refcount::get_with_rc_logic to strip the
reference count. With this change, it now calls either get_raw_bytes
or get_with_rc_stripped as needed.
The reason for this addition is to help with cold storage. We don’t
want to keep refcounts in cold storage which means that we would need
to append dummy refcount to get_raw_bytes calls against cold storage.
By having a separate method which returns values without refcount, we
won’t need to worry about this dummy count.
As a side benefit, this removes a memory allocation when reading
a reference counted column. Previosly get_payload method was used
to strip the refcount:
The issue with it is that it takes a Vec as argument, takes a slice of
it and creates a new Vec from it. Now the vector is simply truncated
by strip_refcount function.