@Description("removes whitespace from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.rightTrim(slice); }
@Description("remove the longest string containing only given characters from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.rightTrim(slice, codePointsToTrim); }
@Benchmark public Slice benchmarkRightTrim(WhitespaceData data) { return rightTrim(data.getRightWhitespace()); }
@Description("removes whitespace from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.rightTrim(slice); }
@Description("removes whitespace from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.rightTrim(slice); }
@Benchmark public Slice benchmarkRightTrim(WhitespaceData data) { return rightTrim(data.getRightWhitespace()); }
@Description("removes whitespace from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.rightTrim(slice); }
private static void assertRightTrim(byte[] sequence) { assertEquals(rightTrim(wrappedBuffer(sequence)), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(sequence), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, new byte[] {'@'})), new int[] {'@'}), wrappedBuffer(sequence)); for (int codePoint : ALL_CODE_POINTS) { if (Character.isWhitespace(codePoint)) { byte[] whitespace = new String(new int[] {codePoint}, 0, 1).getBytes(UTF_8); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace))), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace))), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); } } }
@Description("remove the longest string containing only given characters from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.rightTrim(slice, codePointsToTrim); }
private static void assertRightTrim(byte[] sequence) { assertEquals(rightTrim(wrappedBuffer(sequence)), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(sequence), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, new byte[] {'@'})), new int[] {'@'}), wrappedBuffer(sequence)); for (int codePoint : ALL_CODE_POINTS) { if (Character.isWhitespace(codePoint)) { byte[] whitespace = new String(new int[] {codePoint}, 0, 1).getBytes(UTF_8); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace))), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace))), wrappedBuffer(sequence)); assertEquals(rightTrim(wrappedBuffer(concat(sequence, whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); } } }
@Description("remove the longest string containing only given characters from the end of a string") @ScalarFunction("rtrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice rightTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.rightTrim(slice, codePointsToTrim); }