@NotNull @Override public Bytes<Underlying> write(@NotNull RandomDataInput bytes, long offset, long length) throws BufferUnderflowException, BufferOverflowException { if (length == 8) { writeLong(bytes.readLong(offset)); } else if (length >= 16 && bytes.isDirectMemory()) { rawCopy(bytes, offset, length); } else { BytesInternal.writeFully(bytes, offset, length, this); } return this; }
@NotNull @Override @ForceInline public NativeBytesStore<Underlying> write( long writeOffset, @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException { if (bytes.isDirectMemory()) { memory.copyMemory(bytes.addressForRead(readOffset), addressForWrite(writeOffset), length); } else { write0(writeOffset, bytes, readOffset, length); } return this; }
protected void optimisedWrite(@NotNull RandomDataInput bytes, long offset, long length) { if (length <= safeCopySize() && isDirectMemory() && bytes.isDirectMemory()) { long len = Math.min(writeRemaining(), Math.min(bytes.capacity() - offset, length)); if (len > 0) { long address = bytes.addressForRead(offset); long address2 = addressForWrite(writePosition()); assert address != 0; assert address2 != 0; writeCheckOffset(writePosition(), len); OS.memory().copyMemory(address, address2, len); writeSkip(len); } } else { super.write(bytes, offset, length); } }