Examples of ScriptEvaluator


Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator

    ;
  }
 
  @Test
  public void testBasic() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x * 2; ", Integer.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer(1) });
    assertEquals(result, new Integer(2));
  }
View Full Code Here

Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator

    assertEquals(result, new Integer(2));
  }

  @Test
  public void testVoid() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "int foo = 0; ", Void.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer(1) });
    assertNull(result);
  }
View Full Code Here

Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator

    assertNull(result);
  }

  @Test
  public void testArray() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x; ", Integer[].class, new String[] { "x" }, new Class[] { Integer[].class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer[] { new Integer(1) }});
    assertEquals(((Integer[]) result)[0], new Integer(1));
  }
View Full Code Here

Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator

  }

  @Test
  public void testExternalObject() throws Exception {
    ArrayListMultimap.create();
    ScriptEvaluator script = new ScriptEvaluator(
        javaImports,
        "com.google.common.collect.ArrayListMultimap.create(); new com.cloudera.cdk.morphline.api.Record(); return x.copy(); ",
        Record.class, new String[] { "x" }, new Class[] { Record.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Record() });
    assertEquals(result, new Record());
    assertTrue(result != new Record());
  }
View Full Code Here

Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator

  @Test
  public void testBenchmark() throws Exception {
//    long runs = 3000000000L;
//    long runs = 1000000000;
    long runs = 1000000;
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x; ", Integer.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    long start = System.currentTimeMillis();
    int checksum = 0;
    for (long i = 0; i < runs; i++) {
      Object result = script.evaluate(new Integer(1));
//      Integer result = (Integer) script.evaluate(new Integer(1));
//      Integer result = new Long(i).intValue();
      checksum += (result != null ? 1 : 0);
//      checksum += result;
    }
View Full Code Here

Examples of com.foundationdb.server.service.routines.ScriptEvaluator

    }

    @Override
    public CompoundExplainer getExplainer(ExplainContext context) {
        Attributes atts = new Attributes();
        ScriptEvaluator evaluator = pool.get();
        atts.put(Label.PROCEDURE_IMPLEMENTATION,
                 PrimitiveExplainer.getInstance(evaluator.getEngineName()));
        if (evaluator.isCompiled())
            atts.put(Label.PROCEDURE_IMPLEMENTATION,
                     PrimitiveExplainer.getInstance("compiled"));
        if (evaluator.isShared())
            atts.put(Label.PROCEDURE_IMPLEMENTATION,
                     PrimitiveExplainer.getInstance("shared"));
        pool.put(evaluator, true);       
        return new ServerCallExplainer(getInvocation(), atts, context);
    }
View Full Code Here

Examples of org.codehaus.janino.ScriptEvaluator

          ScriptUtil.class,
          RoleMapping.class,
          HttpServletRequest.class,
      };
     
          ScriptEvaluator se = new ScriptEvaluator(
                  script,
                  Object.class,
                  parameterNames,
                  parameterTypes
              );

              // Evaluate script with actual parameter values.
          result = se.evaluate(parameterValues);
         
          if(result instanceof UEngineException){           
            throw (UEngineException)result;           
          }
    }
View Full Code Here

Examples of org.codehaus.janino.ScriptEvaluator

  public Object scriptEngine(String scriptSmt) throws Exception{
    String[] parameterNames = {};
    Object[] parameterValues = {};
    Class[] parameterTypes = {};
   
      ScriptEvaluator se = new ScriptEvaluator(
          scriptSmt,
              Object.class,
              parameterNames,
              parameterTypes
          );

          // Evaluate script with actual parameter values.
      return se.evaluate(parameterValues);
  }
View Full Code Here

Examples of org.codehaus.janino.ScriptEvaluator

  @Override
  public void start() {
    try {
      assert context != null;
      scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE,
          getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS);
      super.start();
    } catch (Exception e) {
      addError(
          "Could not start evaluator with expression [" + expression + "]", e);
View Full Code Here

Examples of org.codehaus.janino.ScriptEvaluator

  @Override
  public void start() {
    try {
      assert context != null;
      scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE,
          getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS);
      super.start();
    } catch (Exception e) {
      addError(
          "Could not start evaluator with expression [" + expression + "]", e);
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.