public void sync(long position, long length) throws IOException { final long ap = address+position; final long a = (ap)/PAGE_SIZE*PAGE_SIZE; final long l = Math.min(length+(ap-a), address+memory.length()-ap); final int err = msync(a, l); if (err != 0) { throw new IOException("msync failed with error code: "+err); } }
public void munlock(long position, long length) { if (position < 0) throw new IndexOutOfBoundsException(); if (length < 0) throw new IndexOutOfBoundsException(); if (position+length > memory.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.munlock(address+position, length); }
public void munlock(long position, long length) { if (position < 0) throw new IndexOutOfBoundsException(); if (length < 0) throw new IndexOutOfBoundsException(); if (position+length > memory.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.munlock(address+position, length); }
private void refillBuffer(long offset) throws IOException { bufferLen = (int)Math.min(buffer.length, memory.length() - offset); if (bufferLen > 0) { memory.getBytes(offset, buffer, 0, bufferLen); } bufferOffset = offset; bufferPtr = 0; } }
public void mincore(long position, long length, DirectMemory direct) { if (position+length > memory().length()) { throw new IndexOutOfBoundsException(); } final long ap = address+position; final long a = ap/PAGE_SIZE*PAGE_SIZE; final long l = length+(ap-a); if ((l+PAGE_SIZE-1)/PAGE_SIZE > direct.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.mincore(a, l, direct); }
@Override public Void apply(final MMapBuffer b) { //noinspection deprecation madviseDontNeed(b.memory.getAddress(), b.memory.length()); return null; } });
public void mlock(long position, long length) { if (position < 0) throw new IndexOutOfBoundsException(); if (length < 0) throw new IndexOutOfBoundsException(); if (position+length > memory.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.mlock(address+position, length); }
private void refillBuffer(final long offset) throws IOException { bufferLen = (int)Math.min(buffer.length, memory.length() - offset); if (bufferLen > 0) { memory.getBytes(offset, buffer, 0, bufferLen); } bufferOffset = offset; bufferPtr = 0; }
public void advise(long position, long length) throws IOException { final long ap = address+position; final long a = (ap)/PAGE_SIZE*PAGE_SIZE; final long l = Math.min(length+(ap-a), address+memory.length()-ap); final int err = madvise(a, l); if (err != 0) { throw new IOException("madvise failed with error code: "+err); } }
public void mlock(long position, long length) { if (position < 0) throw new IndexOutOfBoundsException(); if (length < 0) throw new IndexOutOfBoundsException(); if (position+length > memory.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.mlock(address+position, length); }
@Override public void close() throws IOException { if (!closed) { closed = true; if (mmapped) { MMapBuffer.munmap(address, memory.length()); } else { if (address != 0) UNSAFE.freeMemory(address); } } }
@Override public void close() throws IOException { if (openBuffersTracker != null) { openBuffersTracker.beforeMMapBufferClosed(this); } //hack to deal with 0 byte files if (address != 0) { if (munmap(address, memory.length()) != 0) throw new IOException("munmap failed [Errno " + errno() + "]"); } }
@Override public void close() { if (mLock) physicalMemory.munlock(0, physicalMemory.memory().length()); runCleaner.set(false); Closeables2.closeQuietly(physicalMemory, log); }
private NativeBuffer createNewAndClose(long newSize) { final NativeBuffer ret = new NativeBuffer(newSize, memory.getOrder()); ret.memory().putBytes(0, memory, 0, Math.min(memory.length(), newSize)); closeQuietly(this); return ret; }