/** Release a direct buffer. {@link #setBuffer(ByteBuffer, int)} should be called before next write operations can be called. * * NOTE: If Cleaner is not accessible due to SecurityManager restrictions, reflection could be used to obtain the "clean" * method and then invoke it. */ public void release () { clear(); UnsafeUtil.releaseBuffer(niobuffer); niobuffer = null; }
/** Release a direct buffer. {@link #setBuffer(ByteBuffer, int)} should be called before next write operations can be called. * * NOTE: If Cleaner is not accessible due to SecurityManager restrictions, reflection could be used to obtain the "clean" * method and then invoke it. */ public void release () { clear(); UnsafeUtil.releaseBuffer(niobuffer); niobuffer = null; }
/** Release a direct buffer. {@link #setBuffer(ByteBuffer, int)} should be called before next write operations can be called. * * NOTE: If Cleaner is not accessible due to SecurityManager restrictions, reflection could be used to obtain the "clean" * method and then invoke it. */ public void release () { clear(); UnsafeUtil.releaseBuffer(niobuffer); niobuffer = null; }
/*** Release a direct buffer. {@link #setBuffer(ByteBuffer, int)} should be called before next write operations can be called. * * NOTE: If Cleaner is not accessible due to SecurityManager restrictions, reflection could be used to obtain the "clean" * method and then invoke it. */ public void release () { clear(); UnsafeUtil.releaseBuffer(niobuffer); niobuffer = null; }
@Override public synchronized long appendEntry(Entry entry) { Assert.isNotNull(entry, "entry"); assertIsOpen(); long index = log.isEmpty() ? 1 : log.lastKey() + 1; kryo.writeClassAndObject(output, entry); byte[] bytes = output.toBytes(); log.put(index, bytes); size += bytes.length; output.clear(); return index; }
@Override public synchronized void compact(long index, Entry entry) throws IOException { Assert.isNotNull(entry, "entry"); assertIsOpen(); kryo.writeClassAndObject(output, entry); byte[] bytes = output.toBytes(); output.clear(); // TODO - calculate newSize by doing the lesser of subtracting out removed entries or adding // remaining entries. log.headMap(index).clear(); log.put(index, bytes); long newSize = 0; for (Map.Entry<Long, byte[]> e : log.entrySet()) { newSize += e.getValue().length; } size = newSize; }