@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.BIGINT) long replacementCodePoint) { if (replacementCodePoint > MAX_CODE_POINT || Character.getType((int) replacementCodePoint) == SURROGATE) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } return SliceUtf8.fixInvalidUtf8(slice, OptionalInt.of((int) replacementCodePoint)); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice) { return SliceUtf8.fixInvalidUtf8(slice); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType("varchar(x)") Slice replacementCharacter) { int count = countCodePoints(replacementCharacter); if (count > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Replacement character string must empty or a single character"); } OptionalInt replacementCodePoint; if (count == 1) { try { replacementCodePoint = OptionalInt.of(getCodePointAt(replacementCharacter, 0)); } catch (InvalidUtf8Exception e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } } else { replacementCodePoint = OptionalInt.empty(); } return SliceUtf8.fixInvalidUtf8(slice, replacementCodePoint); }
public static Slice fixInvalidUtf8(Slice slice) { return fixInvalidUtf8(slice, OptionalInt.of(REPLACEMENT_CODE_POINT)); }
public static Slice fixInvalidUtf8(Slice slice) { return fixInvalidUtf8(slice, OptionalInt.of(REPLACEMENT_CODE_POINT)); }
private static void assertFixInvalidUtf8(Slice testSlice, Slice expectedSlice) { assertEquals(fixInvalidUtf8(testSlice), expectedSlice); }
private static void assertFixInvalidUtf8(Slice testSlice, Slice expectedSlice) { assertEquals(fixInvalidUtf8(testSlice), expectedSlice); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.BIGINT) long replacementCodePoint) { if (replacementCodePoint > MAX_CODE_POINT || Character.getType((int) replacementCodePoint) == SURROGATE) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } return SliceUtf8.fixInvalidUtf8(slice, OptionalInt.of((int) replacementCodePoint)); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.BIGINT) long replacementCodePoint) { if (replacementCodePoint > MAX_CODE_POINT || Character.getType((int) replacementCodePoint) == SURROGATE) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } return SliceUtf8.fixInvalidUtf8(slice, OptionalInt.of((int) replacementCodePoint)); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.BIGINT) long replacementCodePoint) { if (replacementCodePoint > MAX_CODE_POINT || Character.getType((int) replacementCodePoint) == SURROGATE) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } return SliceUtf8.fixInvalidUtf8(slice, OptionalInt.of((int) replacementCodePoint)); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice) { return SliceUtf8.fixInvalidUtf8(slice); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice) { return SliceUtf8.fixInvalidUtf8(slice); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice) { return SliceUtf8.fixInvalidUtf8(slice); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.VARCHAR) Slice replacementCharacter) { int count = countCodePoints(replacementCharacter); if (count > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Replacement character string must empty or a single character"); } OptionalInt replacementCodePoint; if (count == 1) { try { replacementCodePoint = OptionalInt.of(SliceUtf8.getCodePointAt(replacementCharacter, 0)); } catch (InvalidUtf8Exception e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } } else { replacementCodePoint = OptionalInt.empty(); } return SliceUtf8.fixInvalidUtf8(slice, replacementCodePoint); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType("varchar(x)") Slice replacementCharacter) { int count = countCodePoints(replacementCharacter); if (count > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Replacement character string must empty or a single character"); } OptionalInt replacementCodePoint; if (count == 1) { try { replacementCodePoint = OptionalInt.of(getCodePointAt(replacementCharacter, 0)); } catch (InvalidUtf8Exception e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } } else { replacementCodePoint = OptionalInt.empty(); } return SliceUtf8.fixInvalidUtf8(slice, replacementCodePoint); }
@Description("decodes the UTF-8 encoded string") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.VARCHAR) public static Slice fromUtf8(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType("varchar(x)") Slice replacementCharacter) { int count = countCodePoints(replacementCharacter); if (count > 1) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Replacement character string must empty or a single character"); } OptionalInt replacementCodePoint; if (count == 1) { try { replacementCodePoint = OptionalInt.of(getCodePointAt(replacementCharacter, 0)); } catch (InvalidUtf8Exception e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Invalid replacement character"); } } else { replacementCodePoint = OptionalInt.empty(); } return SliceUtf8.fixInvalidUtf8(slice, replacementCodePoint); }