Package com.cloudera.cdk.morphline.scriptengine.java

Examples of com.cloudera.cdk.morphline.scriptengine.java.ScriptEvaluator.evaluate()


  }
 
  @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));
  }

  @Test
  public void testVoid() throws Exception {
View Full Code Here


  }

  @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);
  }

  @Test
  public void testArray() throws Exception {
View Full Code Here

  }

  @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));
  }

  @Test
  public void testExternalObject() throws Exception {
View Full Code Here

    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());
  }

  @Test
View Full Code Here

    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

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.