Skip to content

zero-copy support for Batch #99

Open
@carlsverre

Description

Is your feature request related to a problem? Please describe.
In my project I am commiting data into Fjall using Batch from a iterator of Bytes. The current Batch's insert method only supports taking values by ref (AsRef<&[u8]>) and hence makes a needless copy into UserValue (type alias to Slice).

Describe the solution you'd like
I'd like to minimize needless copies in my write path. Some possible solutions:

  1. modify the insert method to support values that are Into<Slice>. To retain compatibility with existing code this would also require impl<T: AsRef<&[u8]>> From<T> for Slice... which I think should be fine to implement?
  2. add a second insert method to batch that supports this kind of zero copy - could be feature flagged under bytes
  3. extract commit out of Batch and have it take in an iterator of (&Partition, key, value) such that key/value are Into<Slice>

Describe alternatives you've considered
The current work around is just using batch. But it causes a lot of needless allocation.

Additional context
Happy to brainstorm on this!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions