Skip to content

Conversation

@guigzzz
Copy link
Contributor

@guigzzz guigzzz commented Nov 16, 2021

What: Support ArraySegment for underlying array

Why: It's useful to be able to read an SBE message from a view (i.e. ArraySegment) on a big array of bytes, without copies. Currently, we'd have to slice the byte array, which results in a copy.

How: similar to the byte[] case, pin the ArraySegment's underlying buffer so the GC doesn't move it, then offset the created pointer by the ArraySegment offset so that we point to the right memory.

Testing: run unit tests locally with ./runtests

Note: The C# wrappers should really be re-written using structs and Spans, which would enable fast and memory efficient code while still being safe, which the current code is not. Then again, that's a non-trivial undertaking, so this will suffice for now :)

@guigzzz guigzzz marked this pull request as ready for review November 16, 2021 20:30
@mjpt777 mjpt777 merged commit afb62b5 into aeron-io:master Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants