External join (advanded).This example shows a complex use of external join. Its source code is under the samples/java
directory.
import java.io.FileInputStream;
import java.util.Collection;
import java.util.Vector;
public class JavaExternalJoins
{
public static void run(String prefix) throws Exception
{
environment.
setIOConfig(IOHandler.ConfigPropertyBool.KEEPGRAPHOBJECTIDENTIFIERS,
true);
environment.loadSupport(new FileInputStream(prefix + "/bcgct/bucolic/bucolic.bcs"), IOHandler.Format.BCGCT);
Collection<EnvironmentObject> loadedgraphs = environment.loadObjects(new FileInputStream(prefix + "/bcgct/bucolic/sleepandfish.bcg"), IOHandler.Format.BCGCT);
Graph g1 = loadedgraphs.iterator().next().asGraph();
loadedgraphs = environment.loadObjects(new FileInputStream(prefix + "/bcgct/bucolic/simplequery.bcg"), IOHandler.Format.BCGCT);
Graph g2 = loadedgraphs.iterator().next().asGraph();
Vector<GraphObject> ng1 = new Vector<GraphObject>();
Vector<GraphObject> ng2 = new Vector<GraphObject>();
ng1.add(g1.findByIdentifier("c14")); ng2.add(g2.findByIdentifier("c1"));
ng1.add(g1.findByIdentifier("c15")); ng2.add(g2.findByIdentifier("c2"));
GraphSubset subsetg2 = g2.newSubset();
subsetg2.select(g2.findByIdentifier("c1"));
subsetg2.select(g2.findByIdentifier("c2"));
subsetg2.select(g2.findByIdentifier("c3"));
subsetg2.select(g2.findByIdentifier("r2"));
environment.graphExternalJoin(g1, g2, subsetg2, ng1, ng2);
Vector<EnvironmentObject> vout = new Vector<EnvironmentObject>();
vout.add(g1);
System.out.println(environment.saveObjectsString(vout, IOHandler.Format.LINEARFORM));
}
public static void main(String args[]) throws Exception
{
String prefix = "..";
if (args.length == 1)
prefix = args[0];
System.out.println("prefix: " + prefix);
run(prefix);
}
}