@Override public void write(long offset, byte[] bytes, int off, int len) { if (offset < 0 || off + len > bytes.length || offset + len > capacity()) throw new IllegalArgumentException(); getChronicleUnsafe().copyMemory(bytes, BYTES_OFFSET + off, null, start + offset, len); }
@Override public int read(@NotNull byte[] bytes, int off, int len) { if (len < 0 || off < 0 || off + len > bytes.length) throw new IllegalArgumentException(); long left = remaining(); if (left <= 0) return -1; int len2 = (int) Math.min(len, left); getChronicleUnsafe().copyMemory(null, position, bytes, BYTES_OFFSET + off, len2); addPosition(len2); return len2; }
@Override public long readVolatileLong() { long l = getChronicleUnsafe().getLongVolatile(null, position); addPosition(8); return l; }
@Override public void writeByte(long offset, int b) { offsetChecks(offset, 1L); getChronicleUnsafe().putByte(start + offset, (byte) b); }
@Override public void writeOrderedLong(long offset, long v) { offsetChecks(offset, 8L); getChronicleUnsafe().putOrderedLong(null, start + offset, v); }
@Override public void writeFloat(long offset, float v) { offsetChecks(offset, 4L); getChronicleUnsafe().putFloat(start + offset, v); }
@Override public double readDouble() { double d = getChronicleUnsafe().getDouble(position); addPosition(8); return d; }
@Override public void write(int b) { getChronicleUnsafe().putByte(position, (byte) b); incrementPositionAddr(1); }
@Override public void writeByte(long offset, int b) { offsetChecks(offset, 1L); getChronicleUnsafe().putByte(start + offset, (byte) b); }
@Override public void writeChar(int v) { positionChecks(position + 2L); getChronicleUnsafe().putChar(position, (char) v); position += 2L; }
@Override public void writeOrderedInt(int v) { positionChecks(position + 4L); getChronicleUnsafe().putOrderedInt(null, position, v); position += 4L; }
@Override public void readFully(long offset, byte[] bytes, int off, int len) { checkArrayOffs(bytes.length, off, len); getChronicleUnsafe().copyMemory(null, start + offset, bytes, BYTES_OFFSET + off, len); }
@Override public long readLong() { long l = getChronicleUnsafe().getLong(position); addPosition(8); return l; }
@Override public double readDouble() { double d = getChronicleUnsafe().getDouble(position); addPosition(8); return d; }
@Override public void writeShort(long offset, int v) { offsetChecks(offset, 2L); getChronicleUnsafe().putShort(start + offset, (short) v); }
@Override public void writeChar(int v) { positionChecks(position + 2L); getChronicleUnsafe().putChar(position, (char) v); position += 2L; }
@Override public void writeInt(int v) { positionChecks(position + 4L); getChronicleUnsafe().putInt(position, v); position += 4L; }
@Override public void writeInt(long offset, int v) { offsetChecks(offset, 4L); getChronicleUnsafe().putInt(start + offset, v); }
@Override public boolean compareAndSwapLong(long offset, long expected, long x) { offsetChecks(offset, 8L); return getChronicleUnsafe().compareAndSwapLong(null, start + offset, expected, x); }
@Override public void write(RandomDataInput bytes, long position, long length) { if (length > remaining()) throw new IllegalArgumentException("Attempt to write " + length + " bytes with " + remaining() + " remaining"); if (bytes instanceof MappedNativeBytes) { getChronicleUnsafe().copyMemory(((MappedNativeBytes) bytes).start + position, this.position, length); skip(length); } else { super.write(bytes, position, length); } }