-
Notifications
You must be signed in to change notification settings - Fork 58
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
Random access for IOBuffer or a separate random access structure #39
Comments
@elizarov Just pointed me in the direction of |
It is not supposed to be allocated easily. It is a resource that is to be carefully managed. Right now we are thinking that scoped primitive that gives you memory for a while should be Ok. Tell us more about your use-case, though. |
I use manual placement of objects in a JVM Currently I use JVM |
In future, I will probably want to connect to something like Apache Arrow for cross-language data transport and use its memory model, but it is currently out of scope. |
The problem is that different platform has different memory management so it is unclear how can we define an MPP common allocator for
|
I think that for most cases a simple wrapper on top of |
Those extensions couldn't be on top of |
Indeed, but we still need some kind of multiplatform implementation for this. There are several ways to solve that. One is to make primitive read/write members instead of extensions. It will allow to use "slow" access for "slow memory" ( |
Here is the prototype: https://github.com/mipt-npm/kmath/tree/dev/kmath-memory/src/commonMain/kotlin/scientifik/memory Another feature (not really used yet) is a I currently did not implement array reads since I am not sure I understand a use-case for them. They could be done via |
IMO, I think something like that can and should be implemented on top of the current memory class but not necessarily in I'm not sure if this is currently possible as I haven't gotten to this stage in my project yet but the |
I can agree that this is not basically an IO problem. But it seems for me that one A compiler plugin to determine the |
Will the new |
We're rebooting the kotlinx-io development (see #131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version. |
We have a rather unusual application for Buffers (not actually IO). We use buffers in mathematical application for high performance direct allocation of objects in memory. For that we need to be able to allocate one or several continuous memory buffers and be able to create a view (read-only or read-write) with given offset and given size. The whole buffer is allocated and released as a whole.
Currently, I am having following ideas:
Introduce random access read-only and read-write structures. I do not think we should keep
position
fromByteBuffer
as a part of buffer because it complicates things. The Buffer obviously won't inheritInput
orOutput
.Introduce indexed read and write (for mutable version) operations on primitives.
Introduce specifications for read and write of custom objects like it is done in kmath prototype. Those specifications could be used either as contexts for specific operations or passed as parameters for read/write operations on buffers. Those specifications could be used also to create nio-like view buffers.
Introduce buffer windowed views. Meaning a sub-buffer that inherits parent read/write permissions. but could see only limited part of parent buffer. Those could be used for safe operations on buffer.
Further improvement could be achieved by using inline-classes on top of buffer views. If the idea proves to be good, it could later be implemented as a compiler plugin, which will generate specification automatically and allow to create non-boxing arrays.
The text was updated successfully, but these errors were encountered: