use of io.airlift.slice.SliceUtf8.getCodePointAt in project trino by trinodb.
the class CharacterStringCasts method toCodePoints.
private static IntList toCodePoints(Slice slice) {
IntList codePoints = new IntArrayList(slice.length());
for (int offset = 0; offset < slice.length(); ) {
int codePoint = getCodePointAt(slice, offset);
offset += lengthOfCodePoint(slice, offset);
codePoints.add(codePoint);
}
return codePoints;
}
use of io.airlift.slice.SliceUtf8.getCodePointAt in project presto by prestodb.
the class CharacterStringCasts method toCodePoints.
private static List<Integer> toCodePoints(Slice slice) {
ImmutableList.Builder<Integer> codePoints = ImmutableList.builder();
for (int offset = 0; offset < slice.length(); ) {
int codePoint = getCodePointAt(slice, offset);
offset += lengthOfCodePoint(slice, offset);
codePoints.add(codePoint);
}
return codePoints.build();
}
use of io.airlift.slice.SliceUtf8.getCodePointAt in project presto by prestodb.
the class CharacterStringCasts method codePointsToSliceUtf8.
private static Slice codePointsToSliceUtf8(List<Integer> codePoints) {
int length = codePoints.stream().mapToInt(SliceUtf8::lengthOfCodePoint).sum();
Slice result = Slices.wrappedBuffer(new byte[length]);
int offset = 0;
for (int codePoint : codePoints) {
setCodePointAt(codePoint, result, offset);
offset += lengthOfCodePoint(codePoint);
}
return result;
}
use of io.airlift.slice.SliceUtf8.getCodePointAt in project presto by prestodb.
the class StringFunctions method castToCodePoints.
private static int[] castToCodePoints(Slice slice) {
int[] codePoints = new int[safeCountCodePoints(slice)];
int position = 0;
for (int index = 0; index < codePoints.length; index++) {
codePoints[index] = getCodePointAt(slice, position);
position += lengthOfCodePoint(slice, position);
}
return codePoints;
}
Aggregations