use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class PumpTest method getIntRow.
Row getIntRow() {
Row row = new Row();
row.useMemory(new Memory());
row.addColumn(0, "a", "1");
row.addColumn(1, "b", "2");
return row;
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class PumpTest method stopOnError.
@Test(expected = NumberFormatException.class)
public void stopOnError() {
List<Row> inputRows = new ArrayList<>();
inputRows.add(getStringRow());
inputRows.add(getIntRow());
VirtualSinkSource in = new VirtualSinkSource("in", inputRows);
VirtualSinkSource out = new VirtualSinkSource();
Pump cut = new Pump.Engine().from(in).startWith(t -> {
t.getColumnByName("a").convertToInteger();
return t;
}).to(out).build();
cut.start();
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class Expression method execute.
public Row execute(Row input, String expression) {
Bindings bindings = ScriptingEnvironmentProvider.create(manager, this.scriptEngineBindings, input);
try {
this.expressionListener.accept("Executing: " + expression);
Object result = this.engine.eval(expression, bindings);
this.expressionListener.accept("Got result: " + result);
if (!(result instanceof Row)) {
return input;
} else {
return (Row) result;
}
} catch (ScriptException ex) {
throw new IllegalStateException(ex.getMessage(), ex);
}
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class ScriptingEnvironmentProvider method create.
public static Bindings create(ScriptEngineManager scriptEngineManager, Map<String, Object> scriptEngineBindings, Row input) {
Bindings bindings = scriptEngineManager.getBindings();
bindings.put("$ROW", input);
final Row emptyRow = new Row();
bindings.put("$EMPTY", emptyRow);
bindings.put("$MEMORY", input.getMemory());
input.getColumns().forEach(c -> bindings.put(c.getName(), c));
if (scriptEngineBindings != null) {
bindings.putAll(scriptEngineBindings);
}
return bindings;
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class PumpIT method getEntries.
Row getEntries() {
Row row = new Row();
row.addColumn(0, "a", "java");
row.addColumn(1, "b", "tengah");
return row;
}
Aggregations