@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("char(x)") public static Slice charLeftTrim(@SqlType("char(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("remove the longest string containing only given characters from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.leftTrim(slice, codePointsToTrim); }
@Benchmark public Slice benchmarkLeftTrim(WhitespaceData data) { return leftTrim(data.getLeftWhitespace()); }
@Benchmark public Slice benchmarkLeftTrim(WhitespaceData data) { return leftTrim(data.getLeftWhitespace()); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("char(x)") public static Slice charLeftTrim(@SqlType("char(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("char(x)") public static Slice charLeftTrim(@SqlType("char(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
@Description("removes whitespace from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.leftTrim(slice); }
private static void assertLeftTrim(byte[] sequence) { assertEquals(leftTrim(wrappedBuffer(sequence)), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(sequence), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(new byte[] {'@'}, sequence)), 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(leftTrim(wrappedBuffer(concat(whitespace, sequence))), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(whitespace, sequence)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace, sequence)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); } } }
private static void assertLeftTrim(byte[] sequence) { assertEquals(leftTrim(wrappedBuffer(sequence)), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(sequence), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(new byte[] {'@'}, sequence)), 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(leftTrim(wrappedBuffer(concat(whitespace, sequence))), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(whitespace, sequence)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); assertEquals(leftTrim(wrappedBuffer(concat(whitespace, new byte[] {'\r', '\n', '\t', ' '}, whitespace, sequence)), WHITESPACE_CODE_POINTS), wrappedBuffer(sequence)); } } }
@Description("remove the longest string containing only given characters from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.leftTrim(slice, codePointsToTrim); }
@Description("remove the longest string containing only given characters from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.leftTrim(slice, codePointsToTrim); }