presto-spi/src/main/java/io/prestosql/spi/type/Chars.java/Chars/padSpaces
class Chars:    public static Slice padSpaces(Slice slice, int length)
    {
        int textLength = countCodePoints(slice);

        if (textLength > length) {
            throw new IllegalArgumentException("pad length is smaller than slice length");
        }

        if (textLength == length) {
            return slice;
        }

        int bufferSize = slice.length() + length - textLength;
        Slice buffer = Slices.allocate(bufferSize);

        buffer.setBytes(0, slice);

        for (int i = slice.length(); i < bufferSize; ++i) {
            buffer.setByte(i, ' ');
        }

        return buffer;
    }