Skip to content
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

Allocation-free reads #37

Open
scottcarey opened this issue Aug 2, 2019 · 0 comments
Open

Allocation-free reads #37

scottcarey opened this issue Aug 2, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@scottcarey
Copy link

Every read allocates a byte[] on the java heap, even if all that read is going to do is deserialize that byte[] into something else.

It would be useful to be able to read the data directly without the intermediate byte[].

Perhaps with a signature similar to:

<A> A get(byte[] key, Function<DataInput, A> reader);

Access to a (native) ByteBuffer would also be useful, but this will become invalid if the file it points into is garbage collected. A different data structure could 'find' the memory again if it moved due to compaction and otherwise continue to use the old value. That might look like

ValueHandle getValueHandle(byte[] key);

interface ValueHandle {
  boolean updated(); // if the value was updated after the handle was created
  <A> A read(Function<DataInput, A> reader); // read whatever the current value is
}

The purpose of these would be to improve performance by decreasing allocations, and to allow for lazy-deserialization of larger data types. For example one might want to read only part of a value initially, and lazily load the remainder.

@bellofreedom bellofreedom added the enhancement New feature or request label Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants