APISonar


com.facebook.presto.spi.type.StandardTypes.JSON

> com > facebook > presto > spi > type > StandardTypes > JSON
com APIs facebook APIs presto APIs spi APIs type APIs StandardTypes APIs JSON APIs

Example 1
public static Slice jsonExtractScalar(@SqlType(StandardTypes.JSON) Slice json, @SqlType(JsonPathType.NAME) JsonPath jsonPath)
    {
        return JsonExtract.extract(json, jsonPath.getScalarExtractor());
    }
Example 2
public static boolean equals(@SqlType(StandardTypes.JSON) Slice leftJson, @SqlType(StandardTypes.JSON) Slice rightJson)
    {
        return leftJson.equals(rightJson);
    }
Example 3
public static long hashCode(@SqlType(StandardTypes.JSON) Slice value)
    {
        return value.hashCode();
    }
Example 4
public static Slice castToVarchar(@SqlType(StandardTypes.JSON) Slice slice)
    {
        return slice;
    }
Example 5
private static Slice decimalToJson(BigDecimal bigDecimal)
    {
        try {
            SliceOutput dynamicSliceOutput = new DynamicSliceOutput(32);
            try (JsonGenerator jsonGenerator = createJsonGenerator(JSON_FACTORY, dynamicSliceOutput)) {
                jsonGenerator.writeNumber(bigDecimal);
            }
            return dynamicSliceOutput.slice();
        }
        catch (IOException e) {
            throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast '%f' to %s", bigDecimal, StandardTypes.JSON));
        }
    }
Example 6
public static void fail(@SqlType(StandardTypes.JSON) Slice failureInfo)
    {
        throw JSON_CODEC.fromJson(failureInfo.getBytes()).toException();
    }
Example 7
public FunctionInfo specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)
    {
        checkArgument(arity == 1, "Expected arity to be 1");
        Type type = types.get("T");
        MethodHandle methodHandle = METHOD_HANDLE.bindTo(type);
        return operatorInfo(OperatorType.CAST, parseTypeSignature(StandardTypes.JSON), ImmutableList.of(type.getTypeSignature()), methodHandle, false, ImmutableList.of(false));
    }
Example 8
public static Slice jsonParse(@SqlType(StandardTypes.VARCHAR) Slice slice)
    {
        try {
            byte[] in = slice.getBytes();
            SliceOutput dynamicSliceOutput = new DynamicSliceOutput(in.length);
            SORTED_MAPPER.writeValue(dynamicSliceOutput, SORTED_MAPPER.readValue(in, Object.class));
            return dynamicSliceOutput.slice();
        }
        catch (Exception e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Cannot convert '%s' to JSON", slice.toStringUtf8()));
        }
    }
Example 9
public static void fail(@SqlType(StandardTypes.JSON) Slice failureInfoSlice)
    {
        FailureInfo failureInfo = JSON_CODEC.fromJson(failureInfoSlice.getBytes());
        // wrap the failure in a new exception to append the current stack trace
        throw new PrestoException(StandardErrorCode.USER_ERROR, failureInfo.toException());
    }