@Override
    public boolean serialize(ByteBuffer byteBuffer) {
        if (byteBuffer.remaining() < rowDataSize + 4 + (creator.columnCount << 2)) {
            // Fast way to detect whether the remaining cap can hold the serialize data or not.
            // We don't need to be exactualy acurrate.
            return false;
        }

        int sizePos = byteBuffer.position();
        // put size place holder.
        byteBuffer.putInt(0);

        int size = 0;
        for (int colId = 0; colId < creator.columnCount; colId++) {
            byteBuffer.putShort((short) colId);
            size += 2;
            // Store in real type instead of long to reduce size.
            byte type = creator.columnTypes[colId].dataType;
            switch (type) {
                case ColumnType.INT:
                    byteBuffer.putInt(getInt(colId));
                    size += 4;
                    break;
                case ColumnType.LONG:
                    byteBuffer.putLong(getLong(colId));
                    size += 8;
                    break;
                case ColumnType.FLOAT:
                    byteBuffer.putFloat(getFloat(colId));
                    size += 4;
                    break;
                case ColumnType.DOUBLE:
                    byteBuffer.putDouble(getDouble(colId));
                    size += 8;
                    break;
                case ColumnType.STRING:
                    byte[] bytes = getRaw(colId);
                    byteBuffer.putShort((short) bytes.length);
                    byteBuffer.put(bytes);
                    size += 2 + bytes.length;
                    break;
                default:
                    throw new IllegalStateException("column type " + type + " is illegal");
            }
        }
        // Put the size info before.
        byteBuffer.putInt(sizePos, size);
        return true;
    }
The aproximately memeory usage of this object. Currently only return the raw row data size.
indexr-segment/src/main/java/io/indexr/segment/rt/UTF8Row.java