apache / datasketches-memory

High performance native memory access for Java.
https://datasketches.apache.org
Apache License 2.0
118 stars 27 forks source link

Incorrect starting offset while wrapping Memory onto byte array #178

Closed LakshSingla closed 3 months ago

LakshSingla commented 4 months ago

Memory.java#L198, permalink seems incorrect. It initializes the memory with the offset 0, instead of the supplied offset into the array. I might be unclear on the method's contract, but this seems counterintuitive to what I was expecting - an offset of x with length l as an argument means that the memory would be a window into the [x..x+l] bytes of the provided byte array. This is what ByteBuffer.wrap() does.

Is this the expected behavior of the method or is it a bug?

Thanks!

leerho commented 4 months ago

Thank you for finding and reporting this.

That looks like a bug. I'm going to investigate to see if this appears anywhere else.

leerho commented 3 months ago

This fix along with a few other minor issues is now in master and in process for a bug-fix release 2.2.1