@Description("reverse all code points in a given string") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice reverse(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.reverse(slice); }
@Benchmark public Slice benchmarkReverse(BenchmarkData data) { return reverse(data.getSlice()); }
@Description("reverse all code points in a given string") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice reverse(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.reverse(slice); }
@Benchmark public Slice benchmarkReverse(BenchmarkData data) { return reverse(data.getSlice()); }
@Description("reverse all code points in a given string") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice reverse(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.reverse(slice); }
@Description("reverse all code points in a given string") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice reverse(@SqlType("varchar(x)") Slice slice) { return SliceUtf8.reverse(slice); }
private static void assertReverse(String string) { Slice actualReverse = reverse(utf8Slice(string)); int[] codePoints = string.codePoints().toArray(); codePoints = Ints.toArray(Lists.reverse(Ints.asList(codePoints))); Slice expectedReverse = wrappedBuffer(new String(codePoints, 0, codePoints.length).getBytes(UTF_8)); assertEquals(actualReverse, expectedReverse); }
private static void assertReverse(String string) { Slice actualReverse = reverse(utf8Slice(string)); int[] codePoints = string.codePoints().toArray(); codePoints = Ints.toArray(Lists.reverse(Ints.asList(codePoints))); Slice expectedReverse = wrappedBuffer(new String(codePoints, 0, codePoints.length).getBytes(UTF_8)); assertEquals(actualReverse, expectedReverse); }
private static void assertReverseWithInvalidSequence(byte[] invalidSequence) { assertEquals( reverse(wrappedBuffer(invalidSequence)), wrappedBuffer(invalidSequence)); assertEquals( reverse(wrappedBuffer(concat(new byte[] {'a', 'b', 'c'}, invalidSequence))), wrappedBuffer(concat(invalidSequence, new byte[] {'c', 'b', 'a'}))); assertEquals( reverse(wrappedBuffer(concat(invalidSequence, new byte[] {'x', 'y', 'z'}))), wrappedBuffer(concat(new byte[] {'z', 'y', 'x'}, invalidSequence))); assertEquals( reverse(wrappedBuffer(concat(new byte[] {'a', 'b', 'c'}, invalidSequence, new byte[] {'x', 'y', 'z'}))), wrappedBuffer(concat(new byte[] {'z', 'y', 'x'}, invalidSequence, new byte[] {'c', 'b', 'a'}))); }
private static void assertReverseWithInvalidSequence(byte[] invalidSequence) { assertEquals( reverse(wrappedBuffer(invalidSequence)), wrappedBuffer(invalidSequence)); assertEquals( reverse(wrappedBuffer(concat(new byte[] {'a', 'b', 'c'}, invalidSequence))), wrappedBuffer(concat(invalidSequence, new byte[] {'c', 'b', 'a'}))); assertEquals( reverse(wrappedBuffer(concat(invalidSequence, new byte[] {'x', 'y', 'z'}))), wrappedBuffer(concat(new byte[] {'z', 'y', 'x'}, invalidSequence))); assertEquals( reverse(wrappedBuffer(concat(new byte[] {'a', 'b', 'c'}, invalidSequence, new byte[] {'x', 'y', 'z'}))), wrappedBuffer(concat(new byte[] {'z', 'y', 'x'}, invalidSequence, new byte[] {'c', 'b', 'a'}))); }