presto-spi/src/main/java/io/prestosql/spi/type/Chars.java/Chars/byteCountWithoutTrailingSpace
class Chars:    public static int byteCountWithoutTrailingSpace(Slice slice, int offset, int length)
    {
        requireNonNull(slice, "slice is null");
        if (length < 0) {
            throw new IllegalArgumentException("length must be greater than or equal to zero");
        }
        if (offset < 0 || offset + length > slice.length()) {
            throw new IllegalArgumentException("invalid offset/length");
        }
        for (int i = length + offset; i > offset; i--) {
            if (slice.getByte(i - 1) != ' ') {
                return i - offset;
            }
        }
        return 0;
    }