Examples of JsonValueJsonExtractor


Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

                        methodHandle = constantJsonExtract;
                        jsonExtractor = generateExtractor(pattern, new ScalarValueJsonExtractor());
                        break;
                    case JSON_EXTRACT_FUNCTION_NAME:
                        methodHandle = constantJsonExtract;
                        jsonExtractor = generateExtractor(pattern, new JsonValueJsonExtractor());
                        break;
                    case JSON_SIZE_FUNCTION_NAME:
                        methodHandle = constantJsonSize;
                        jsonExtractor = generateExtractor(pattern, new JsonSizeExtractor());
                        break;
                    default:
                        throw new IllegalArgumentException("Unsupported method " + name);
                }

                methodHandle = MethodHandles.insertArguments(methodHandle, 1, jsonExtractor);

                // remove the pattern argument
                arguments = new ArrayList<>(arguments);
                arguments.remove(1);
                arguments = ImmutableList.copyOf(arguments);
            }
            else {
                JsonExtractCache<?> cache;
                switch (name) {
                    case JSON_EXTRACT_SCALAR_FUNCTION_NAME:
                        methodHandle = dynamicJsonExtract;
                        cache = new JsonExtractCache<>(20, new Supplier<JsonExtractor<Slice>>()
                        {
                            @Override
                            public JsonExtractor<Slice> get()
                            {
                                return new ScalarValueJsonExtractor();
                            }
                        });
                        break;
                    case JSON_EXTRACT_FUNCTION_NAME:
                        methodHandle = dynamicJsonExtract;
                        cache = new JsonExtractCache<>(20, new Supplier<JsonExtractor<Slice>>()
                        {
                            @Override
                            public JsonExtractor<Slice> get()
                            {
                                return new JsonValueJsonExtractor();
                            }
                        });
                        break;
                    case JSON_SIZE_FUNCTION_NAME:
                        methodHandle = dynamicJsonSize;
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    @Test
    public void testJsonValueJsonExtractor()
            throws Exception
    {
        JsonValueJsonExtractor extractor = new JsonValueJsonExtractor();

        // Check scalar values
        assertEquals(doExtract(extractor, "123"), "123");
        assertEquals(doExtract(extractor, "-1"), "-1");
        assertEquals(doExtract(extractor, "0.01"), "0.01");
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    }

    private static String doJsonExtract(String inputJson, String jsonPath)
            throws IOException
    {
        Slice value = JsonExtract.extract(Slices.utf8Slice(inputJson), generateExtractor(jsonPath, new JsonValueJsonExtractor()));
        return (value == null) ? null : value.toString(Charsets.UTF_8);
    }
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    @Test
    public void testJsonVaueJsonExtractor()
            throws Exception
    {
        JsonValueJsonExtractor extractor = new JsonValueJsonExtractor();

        // Check scalar values
        assertEquals(doExtract(extractor, "123"), "123");
        assertEquals(doExtract(extractor, "-1"), "-1");
        assertEquals(doExtract(extractor, "0.01"), "0.01");
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    @Test
    public void testJsonValueJsonExtractor()
            throws Exception
    {
        JsonValueJsonExtractor extractor = new JsonValueJsonExtractor();

        // Check scalar values
        assertEquals(doExtract(extractor, "123"), "123");
        assertEquals(doExtract(extractor, "-1"), "-1");
        assertEquals(doExtract(extractor, "0.01"), "0.01");
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    }

    private static String doJsonExtract(String inputJson, String jsonPath)
            throws IOException
    {
        Slice value = JsonExtract.extractInternal(Slices.wrappedBuffer(inputJson.getBytes(Charsets.UTF_8)), generateExtractor(jsonPath, new JsonValueJsonExtractor()));
        return (value == null) ? null : value.toString(Charsets.UTF_8);
    }
View Full Code Here

Examples of com.facebook.presto.operator.scalar.JsonExtract.JsonValueJsonExtractor

    @Test
    public void testJsonVaueJsonExtractor()
            throws Exception
    {
        JsonValueJsonExtractor extractor = new JsonValueJsonExtractor();

        // Check scalar values
        assertEquals(doExtract(extractor, "123"), "123");
        assertEquals(doExtract(extractor, "-1"), "-1");
        assertEquals(doExtract(extractor, "0.01"), "0.01");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.