@Override
    public RowData copy(RowData from) {
        if (from.getArity() != types.length) {
            throw new IllegalArgumentException(
                    "Row arity: " + from.getArity() + ", but serializer arity: " + types.length);
        }
        if (from instanceof BinaryRowData) {
            return ((BinaryRowData) from).copy();
        } else if (from instanceof NestedRowData) {
            return ((NestedRowData) from).copy();
        } else {
            return copyRowData(from, new GenericRowData(from.getArity()));
        }
    }
@Test
    protected void testCopy() {
        for (RowData row : testData) {
            checkDeepEquals(row, serializer.copy(row), true);
        }

        for (RowData row : testData) {
            checkDeepEquals(row, serializer.copy(row, new GenericRowData(row.getArity())), true);
        }

        for (RowData row : testData) {
            checkDeepEquals(
                    row,
                    serializer.copy(
                            serializer.toBinaryRow(row), new GenericRowData(row.getArity())),
                    false);
        }

        for (RowData row : testData) {
            checkDeepEquals(row, serializer.copy(serializer.toBinaryRow(row)), false);
        }

        for (RowData row : testData) {
            checkDeepEquals(
                    row,
                    serializer.copy(serializer.toBinaryRow(row), new BinaryRowData(row.getArity())),
                    false);
        }
    }