@Override protected Long writeMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) { int keyLength = totalLength(keyBuffers); int valueLength = totalLength(valueBuffers); long address = storageArea.allocate(keyLength + valueLength + HEADER_SIZE); if (address >= 0) { storageArea.writeInt(address + KEY_HASH_OFFSET, hash); storageArea.writeInt(address + KEY_LENGTH_OFFSET, keyLength); storageArea.writeInt(address + VALUE_LENGTH_OFFSET, valueLength); storageArea.writeBuffers(address + DATA_OFFSET, keyBuffers); storageArea.writeBuffers(address + DATA_OFFSET + keyLength, valueBuffers); return address; } else { return null; } }
@Override protected Long writeMappingBuffersGathering(ByteBuffer[] keyBuffers, ByteBuffer[] valueBuffers, int hash) { int keyLength = totalLength(keyBuffers); int valueLength = totalLength(valueBuffers); long address = storageArea.allocate(keyLength + valueLength + HEADER_SIZE); if (address >= 0) { storageArea.writeInt(address + KEY_HASH_OFFSET, hash); storageArea.writeInt(address + KEY_LENGTH_OFFSET, keyLength); storageArea.writeInt(address + VALUE_LENGTH_OFFSET, valueLength); storageArea.writeBuffers(address + DATA_OFFSET, keyBuffers); storageArea.writeBuffers(address + DATA_OFFSET + keyLength, valueBuffers); return address; } else { return null; } }
if (relocated >= 0) { if (relocated < target) { writeBuffers(relocated, readBuffers(target, sizeOfArea)); if (!owner.moved(target, relocated)) { throw new AssertionError("Failure to move mapping during release");
if (relocated >= 0) { if (relocated < target) { writeBuffers(relocated, readBuffers(target, sizeOfArea)); if (!owner.moved(target, relocated)) { throw new AssertionError("Failure to move mapping during release");
private boolean compress() { long lastAddress = allocator.getLastUsedPointer(); int sizeOfArea = owner.sizeOf(lastAddress); long compressed = allocator.allocate(sizeOfArea); if (compressed >= 0) { if (compressed < lastAddress) { writeBuffers(compressed, readBuffers(lastAddress, sizeOfArea)); if (owner.moved(lastAddress, compressed)) { allocator.free(lastAddress); return true; } } allocator.free(compressed); return false; } else { return false; } }
private boolean compress() { long lastAddress = allocator.getLastUsedPointer(); int sizeOfArea = owner.sizeOf(lastAddress); long compressed = allocator.allocate(sizeOfArea); if (compressed >= 0) { if (compressed < lastAddress) { writeBuffers(compressed, readBuffers(lastAddress, sizeOfArea)); if (owner.moved(lastAddress, compressed)) { allocator.free(lastAddress); return true; } } allocator.free(compressed); return false; } else { return false; } }