void (final ByteBuffer target, final int offset, final int capacity, final int length, final int redirectToId, final ByteBuffer payload) { if (capacity < MIN_CAPACITY || capacity > MAX_CAPACITY) { throw new IllegalArgumentException("capacity(" + capacity + ") must be in [" + MIN_CAPACITY + ".." + MAX_CAPACITY + "]"); } if (length != 0) { throw new IllegalArgumentException("length(" + length + ") must be in 0 for MOVED records"); } final int capacityOverFirstBucket = capacity - MIN_CAPACITY; if ((capacityOverFirstBucket % OFFSET_BUCKET) != 0) { throw new IllegalArgumentException("capacity-MIN (=" + capacityOverFirstBucket + ") must be rounded up to " + OFFSET_BUCKET); } final int packedCapacity = capacityOverFirstBucket >> OFFSET_BUCKET_BITS; final int highest6BitsOfCapacity = packedCapacity >> CAPACITY_BITS_1_2; final byte headerByte0 = (byte)(RECORD_TYPE_MOVED | highest6BitsOfCapacity); final short headerBytes1_2 = (short)(packedCapacity & CAPACITY_MASK_1_2); target.put(offset, headerByte0); target.putShort(offset + 1, headerBytes1_2); target.putInt(offset + REDIRECT_TO_OFFSET, redirectToId); }