OuterInnerDirectionalGraph graph = new OuterInnerDirectionalGraph(numStreams);
for (int i = 0; i < outerJoinDescList.size(); i++)
{
OuterJoinDesc desc = outerJoinDescList.get(i);
int streamMax = i + 1; // the outer join must references streams less then streamMax
// Check outer join on-expression, if provided
int streamOne;
int streamTwo;
int lowerStream;
int higherStream;
if (desc.getOptLeftNode() != null) {
streamOne = desc.getOptLeftNode().getStreamId();
streamTwo = desc.getOptRightNode().getStreamId();
if ((streamOne > streamMax) || (streamTwo > streamMax) ||
(streamOne == streamTwo))
{
throw new IllegalArgumentException("Outer join descriptors reference future streams, or same streams");
}
// Determine who is the first stream in the streams listed
lowerStream = streamOne;
higherStream = streamTwo;
if (streamOne > streamTwo)
{
lowerStream = streamTwo;
higherStream = streamOne;
}
}
else {
streamOne = i;
streamTwo = i + 1;
lowerStream = i;
higherStream = i + 1;
graph.addUnqualifiedNavigable(streamOne, streamTwo);
}
// Add to graph
if (desc.getOuterJoinType() == OuterJoinType.FULL)
{
graph.add(streamOne, streamTwo);
graph.add(streamTwo, streamOne);
}
else if (desc.getOuterJoinType() == OuterJoinType.LEFT)
{
graph.add(lowerStream, higherStream);
}
else if (desc.getOuterJoinType() == OuterJoinType.RIGHT)
{
graph.add(higherStream, lowerStream);
}
else if (desc.getOuterJoinType() == OuterJoinType.INNER)
{
// no navigability for inner joins
}
else
{
throw new IllegalArgumentException("Outer join descriptors join type not handled, type=" + desc.getOuterJoinType());
}
}
return graph;
}