xerial / larray

Large off-heap arrays and mmap files for Scala and Java
Apache License 2.0
400 stars 43 forks source link

Copying one MappedLByteArray into another MappedLByteArray #71

Open huntc opened 4 years ago

huntc commented 4 years ago

It doesn't appear as though there's a straightforward way of copying the contents of a buffer produced by LArray.mmap into another buffer produced by LArray.mmap. LArray.mmap returns a MappedLByteArray whereas its copyTo method requires the target to be an LByteArray.

Any advice? Thanks.

huntc commented 4 years ago

For reference: my work-around is this:

UnsafeUtil.unsafe.copyMemory(
  sourceBuffer.address,
  targetBuffer.address + targetOffset,
  sourceBuffer.length
)