Creating output
Tuesday, March 01, 2011
9:15 AM
Creating output
It's obvious how to create output in the base types. 
How does one create Tuple(tuple) or DataBag(bag) output? 
Tuples are created via a factory: 
Tuple t = TupleFactory.getInstance().newTuple(element1, element2, ...);
Why? The stated reason is so users can change how tuples are stored. 
Bags are created via a factory: 
TupleFactory mTupleFactory = TupleFactory.getInstance();
BagFactory mBagFactory = BagFactory.getInstance();            
DataBag output = mBagFactory.newDefaultBag();
...
output.add(mTupleFactory.newTuple(...);
Pasted from <[link]> 
A DataBag can only contain Tuples (that may, of course, contain DataBags as arguments). 