Package org.elasticsearch.script

Examples of org.elasticsearch.script.ExecutableScript.run()


        ctx.put("value", 1);
        Object o = script.run();
        assertThat(((Number) o).intValue(), equalTo(1));

        ctx.put("value", 2);
        o = script.run();
        assertThat(((Number) o).intValue(), equalTo(2));
    }

    @Test
    public void testChangingVarsCrossExecution2() {
View Full Code Here


        Map<String, Object> ctx = new HashMap<String, Object>();
        Object compiledScript = se.compile("value");

        ExecutableScript script = se.executable(compiledScript, vars);
        script.setNextVar("value", 1);
        Object o = script.run();
        assertThat(((Number) o).intValue(), equalTo(1));

        script.setNextVar("value", 2);
        o = script.run();
        assertThat(((Number) o).intValue(), equalTo(2));
View Full Code Here

        script.setNextVar("value", 1);
        Object o = script.run();
        assertThat(((Number) o).intValue(), equalTo(1));

        script.setNextVar("value", 2);
        o = script.run();
        assertThat(((Number) o).intValue(), equalTo(2));
    }
}
View Full Code Here

                        Map<String, Object> vars = new HashMap<String, Object>();
                        vars.put("x", x);
                        vars.put("y", y);
                        ExecutableScript script = se.executable(compiled, vars);
                        for (int i = 0; i < 100000; i++) {
                            long result = ((Number) script.run()).longValue();
                            assertThat(result, equalTo(addition));
                        }
                    } catch (Throwable t) {
                        failed.set(true);
                        logger.error("failed", t);
View Full Code Here

        System.out.println("Execute Took: " + stopWatch.stop().lastTaskTime());

        stopWatch = new StopWatch().start();
        ExecutableScript executableScript = se.executable(compiled, vars);
        for (long i = 0; i < ITER; i++) {
            executableScript.run();
        }
        System.out.println("Executable Took: " + stopWatch.stop().lastTaskTime());

        stopWatch = new StopWatch().start();
        executableScript = se.executable(compiled, vars);
View Full Code Here

        executableScript = se.executable(compiled, vars);
        for (long i = 0; i < ITER; i++) {
            for (Map.Entry<String, Object> entry : vars.entrySet()) {
                executableScript.setNextVar(entry.getKey(), entry.getValue());
            }
            executableScript.run();
        }
        System.out.println("Executable (vars) Took: " + stopWatch.stop().lastTaskTime());
    }
}
View Full Code Here

            try {
                final CompiledScript compiledScript = scriptService.compile(
                        lang, script, scriptType);
                ExecutableScript executable = scriptService.executable(
                        compiledScript, localVars);
                Object result = executable.run();
                logger.info("[{}] \"{}\" => {}", target, script, result);
            } catch (final Exception e) {
                logger.warn("Failed to execute script: {}", e, script);
            }
        }
View Full Code Here

                params = new HashMap<String, Object>();
            }
            params.put("facets", facetObjects);
            params.put("_client", client);
            ExecutableScript script = scriptService.executable(firstFacet.scriptLang(), firstFacet.reduceScript(), params);
            facet = script.run();
        } else {
            facet = facetObjects;
        }
        return new InternalScriptFacet(firstFacet.getName(), facet, firstFacet.scriptLang(), firstFacet.reduceScript(), firstFacet.reduceParams(), scriptService, client);
    }
View Full Code Here

        final ScriptService scriptService = riverConfig.getScriptService();
        final CompiledScript compiledScript = scriptService.compile(lang,
                script, scriptType);
        ExecutableScript executable = scriptService.executable(compiledScript,
                vars);
        return executable.run();
    }

    protected ScriptInfo getScriptValue(final Map<String, Object> params) {
        final Object value = SettingsUtils.get(params, SCRIPT_QUERY_TYPE, null);
        if (value == null) {
View Full Code Here

    params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1");
    params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "1", "value", "A"));

    ExecutableScript script = factory.newScript(params);
    script.setNextVar("ctx", ImmutableMap.of("_source", source));
    script.run();

    mapFields = (Collection) source.get(listField);
    System.out.println("source = " + source);
    assertThat(mapFields).hasSize(1);
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.