protected void processIteration(Object[] iterationInputs)
throws ActivityProcessingException,
ActivityTerminatedException,
ActivityUserException
{
TupleListIterator tuples1 = (TupleListIterator)iterationInputs[0];
TupleListIterator tuples2 = (TupleListIterator)iterationInputs[1];
String script = (String)iterationInputs[2];
String language = (String)iterationInputs[3];
LOG.debug("Running script on engine '" + language + "' :\n" + script);
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName(language);
try
{
engine.eval(script);
Invocable inv = (Invocable)engine;
TupleJoin join = inv.getInterface(TupleJoin.class);
TupleMetadata outputMetadata =
join.getMetadata(
(TupleMetadata)tuples1.getMetadataWrapper().getMetadata(),
(TupleMetadata)tuples2.getMetadataWrapper().getMetadata());
Tuple tuple;
// Store data1 input stream
List<Tuple> data1 = new LinkedList<Tuple>();
while ((tuple = (Tuple)tuples1.nextValue()) != null)
{
data1.add(tuple);
}
mOutput.write(ControlBlock.LIST_BEGIN);
mOutput.write(outputMetadata);
Tuple tuple2;
while ((tuple2 = (Tuple)tuples2.nextValue()) != null)
{
for (Tuple tuple1 : data1)
{
List<Tuple> result = join.process(tuple1, tuple2);
if (result != null)