@Override public byte readByte(long offset) { return getChronicleUnsafe().getByte(start + offset); }
@Override public byte readByte(long offset) { return getChronicleUnsafe().getByte(start + offset); }
@Override public byte readByte() { byte aByte = getChronicleUnsafe().getByte(position); addPosition(1); return aByte; }
@Override public Bytes load() { ChronicleUnsafe unsafe = getChronicleUnsafe(); int pageSize = unsafe.pageSize(); for (long addr = start; addr < capacity; addr += pageSize) unsafe.getByte(addr); return this; }
@Override public byte readByte() { byte aByte = getChronicleUnsafe().getByte(position); addPosition(1); return aByte; }
@Override public Bytes load() { ChronicleUnsafe unsafe = getChronicleUnsafe(); int pageSize = unsafe.pageSize(); for (long addr = start; addr < capacity; addr += pageSize) unsafe.getByte(addr); return this; }
private Bytes zeroOutDirty(long start, long end) { if (start < 0 || end > limit()) throw new IllegalArgumentException("start: " + start + ", end: " + end); if (start >= end) return this; // get unaligned leading bytes ChronicleUnsafe unsafe = getChronicleUnsafe(); while (start < end && (start & 7) != 0) { byte b = unsafe.getByte(this.start + start); if (b != 0) unsafe.putByte(this.start + start, (byte) 0); start++; } // check 64-bit aligned access while (start < end - 7) { long l = unsafe.getLong(this.start + start); if (l != 0) unsafe.putLong(this.start + start, 0L); start += 8; } // check unaligned tail while (start < end) { byte b = unsafe.getByte(this.start + start); if (b != 0) unsafe.putByte(this.start + start, (byte) 0); start++; } return this; }
private Bytes zeroOutDirty(long start, long end) { if (start < 0 || end > limit()) throw new IllegalArgumentException("start: " + start + ", end: " + end); if (start >= end) return this; // get unaligned leading bytes ChronicleUnsafe unsafe = getChronicleUnsafe(); while (start < end && (start & 7) != 0) { byte b = unsafe.getByte(this.start + start); if (b != 0) unsafe.putByte(this.start + start, (byte) 0); start++; } // check 64-bit aligned access while (start < end - 7) { long l = unsafe.getLong(this.start + start); if (l != 0) unsafe.putLong(this.start + start, 0L); start += 8; } // check unaligned tail while (start < end) { byte b = unsafe.getByte(this.start + start); if (b != 0) unsafe.putByte(this.start + start, (byte) 0); start++; } return this; }
@Override public void readObject(Object object, int start, int end) { int len = end - start; if (position + len >= limit) throw new IndexOutOfBoundsException("Length out of bounds len: " + len); ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; len >= 8; len -= 8) { unsafe.putLong(object, (long) start, unsafe.getLong(position)); incrementPositionAddr(8L); start += 8; } for (; len > 0; len--) { unsafe.putByte(object, (long) start, unsafe.getByte(position)); incrementPositionAddr(1L); start++; } }
@Override public void readObject(Object object, int start, int end) { int len = end - start; if (position + len >= limit) throw new IndexOutOfBoundsException("Length out of bounds len: " + len); ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; len >= 8; len -= 8) { unsafe.putLong(object, (long) start, unsafe.getLong(position)); incrementPositionAddr(8L); start += 8; } for (; len > 0; len--) { unsafe.putByte(object, (long) start, unsafe.getByte(position)); incrementPositionAddr(1L); start++; } }
@Override public void writeObject(Object object, int start, int end) { int len = end - start; ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; len >= 8; len -= 8) { positionChecks(position + 8L); unsafe.putLong(position, unsafe.getLong(object, (long) start)); position += 8; start += 8; } for (; len > 0; len--) { positionChecks(position + 1L); unsafe.putByte(position, unsafe.getByte(object, (long) start)); position++; start++; } }
@Override public void writeObject(Object object, int start, int end) { int len = end - start; ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; len >= 8; len -= 8) { positionChecks(position + 8L); unsafe.putLong(position, unsafe.getLong(object, (long) start)); position += 8; start += 8; } for (; len > 0; len--) { positionChecks(position + 1L); unsafe.putByte(position, unsafe.getByte(object, (long) start)); position++; start++; } }
@Override public boolean compare(long offset, RandomDataInput input, long inputOffset, long len) { if (offset < 0 || inputOffset < 0 || len < 0) throw new IndexOutOfBoundsException(); if (offset + len < 0 || offset + len > capacity() || inputOffset + len < 0 || inputOffset + len > input.capacity()) { return false; } long i = 0L; ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; i < len - 7L; i += 8L) { if (unsafe.getLong(start + offset + i) != input.readLong(inputOffset + i)) return false; } if (i < len - 3L) { if (unsafe.getInt(start + offset + i) != input.readInt(inputOffset + i)) return false; i += 4L; } if (i < len - 1L) { if (unsafe.getChar(start + offset + i) != input.readChar(inputOffset + i)) return false; i += 2L; } if (i < len) { if (unsafe.getByte(start + offset + i) != input.readByte(inputOffset + i)) return false; } return true; }
@Override public boolean compare(long offset, RandomDataInput input, long inputOffset, long len) { if (offset < 0 || inputOffset < 0 || len < 0) throw new IndexOutOfBoundsException(); if (offset + len < 0 || offset + len > capacity() || inputOffset + len < 0 || inputOffset + len > input.capacity()) { return false; } long i = 0L; ChronicleUnsafe unsafe = getChronicleUnsafe(); for (; i < len - 7L; i += 8L) { if (unsafe.getLong(start + offset + i) != input.readLong(inputOffset + i)) return false; } if (i < len - 3L) { if (unsafe.getInt(start + offset + i) != input.readInt(inputOffset + i)) return false; i += 4L; } if (i < len - 1L) { if (unsafe.getChar(start + offset + i) != input.readChar(inputOffset + i)) return false; i += 2L; } if (i < len) { if (unsafe.getByte(start + offset + i) != input.readByte(inputOffset + i)) return false; } return true; }