public DataBag exec(Tuple input) throws IOException { try { DataBag bag = BagFactory.getInstance().newDefaultBag(); for (int i = 0; i < input.size(); i++) { final Object object = input.get(i); if (object instanceof Tuple) { for (int j = 0; j < ((Tuple) object).size(); j++) { Tuple tp2 = TupleFactory.getInstance().newTuple(1); tp2.set(0, ((Tuple) object).get(j)); bag.add(tp2); } } else { Tuple tp2 = TupleFactory.getInstance().newTuple(1); tp2.set(0, object); bag.add(tp2); } } return bag; } catch (Exception ee) { throw new RuntimeException("Error while creating a bag", ee); } }