/** * Change the position acknowleging there is no thread safety assumptions. Best effort setting * is fine. * * * @param position to set if we can. * @return this */ public NativeBytes lazyPosition(long position) { if (position < 0 || position > limit()) throw new IndexOutOfBoundsException("position: " + position + " limit: " + limit()); // assume we don't need to no check thread safety. positionAddr(startAddr + position); return this; }
/** * Change the position acknowleging there is no thread safety assumptions. Best effort setting * is fine. * * * @param position to set if we can. * @return this */ public NativeBytes lazyPosition(long position) { if (position < 0 || position > limit()) throw new IndexOutOfBoundsException("position: " + position + " limit: " + limit()); // assume we don't need to no check thread safety. positionAddr(startAddr + position); return this; }
@Override public Bytes zeroOut(long start, long end) { if (start < 0 || end > limit()) throw new IllegalArgumentException("start: " + start + ", end: " + end); if (start >= end) return this; UNSAFE.setMemory(startAddr + start, end - start, (byte) 0); return this; }
@Override public Bytes zeroOut(long start, long end) { if (start < 0 || end > limit()) throw new IllegalArgumentException("start: " + start + ", end: " + end); if (start >= end) return this; UNSAFE.setMemory(startAddr + start, end - start, (byte) 0); 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 while (start < end && (start & 7) != 0) { byte b = UNSAFE.getByte(startAddr + start); if (b != 0) UNSAFE.putByte(startAddr + start, (byte) 0); start++; } // check 64-bit aligned access while (start < end - 7) { long l = UNSAFE.getLong(startAddr + start); if (l != 0) UNSAFE.putLong(startAddr + start, 0L); start += 8; } // check unaligned tail while (start < end) { byte b = UNSAFE.getByte(startAddr + start); if (b != 0) UNSAFE.putByte(startAddr + 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 while (start < end && (start & 7) != 0) { byte b = UNSAFE.getByte(startAddr + start); if (b != 0) UNSAFE.putByte(startAddr + start, (byte) 0); start++; } // check 64-bit aligned access while (start < end - 7) { long l = UNSAFE.getLong(startAddr + start); if (l != 0) UNSAFE.putLong(startAddr + start, 0L); start += 8; } // check unaligned tail while (start < end) { byte b = UNSAFE.getByte(startAddr + start); if (b != 0) UNSAFE.putByte(startAddr + start, (byte) 0); start++; } return this; }