TheseusBox is the name of an API that allows you to easily incorporate Theseus functionality into your existing Java applications. Using TheseusBox involves calling a special library function with a plan (in plaintext or in a file) and input data (in plaintext or as Relation objects) and then unwrapping its output.
To use the TheseusBox API, you simply need to do the following:
As an example, consider the following code:
import theseus.api.Relation;
import theseus.api.AttrList;
import theseus.api.Tuple;
import theseus.api.TheseusBox;
...
...
...
try {
String plan = "PLAN p { INPUT: stream s1, stream s2 "+
"OUTPUT: stream s3 BODY { union (s1, s2 : s3) } }";
Relation[] inRel = new Relation[2];
AttrList aLst1 = new AttrList("name char");
inRel[0] = new Relation("s1", aLst1);
inRel[0].addTuple(new Tuple(aLst1, "Lucy"));
inRel[0].addTuple(new Tuple(aLst1, "Ricky"));
AttrList aLst2 = new AttrList("name char");
inRel[1] = new Relation("s2", aLst2);
inRel[1].addTuple(new Tuple(aLst2, "Fred"));
inRel[1].addTuple(new Tuple(aLst2, "Ethel"));
TheseusBox b = new TheseusBox();
Relation[] outRel = b.executePlan(plan, inRel);
if (outRel != null)
for (int i=0; i<outRel.length; i++)
System.out.println(outRel[i]);
}
catch (Exception e) {
e.printStackTrace();
}
|
RELATION NAME: ATTRIBUTE LIST: name char -------------------------------------------------- 000: Ricky 001: Ethel 002: Fred 003: Lucy -------------------------------------------------- |
The complete code for this example can be found in the "src" directory of your Theseus installation.