@Override
    public void setToNative(long i, Object value)
    {
        if (value == null) {
            objectLengths.setShort(i, (short) -1);
        } else {
            byte[] ba = toByteArray(value);
            if (ba.length > maxObjectLength) {
                throw new IllegalArgumentException("Object  " + value + " is too long.");
            }
            int objLen = ba.length;
            if (objLen > Short.MAX_VALUE) {
                throw new IllegalArgumentException("Object  " + value + " is too long.");
            }
            objectLengths.setShort(i, (short) objLen);
            long offset = sizeof * i * maxObjectLength;
            for (int j = 0; j < objLen; j++) {
                Utilities.UNSAFE.putByte(ptr + offset + sizeof * j, ba[j]);
            }
        }
    }