private void addJoinConditionToGraph( VariableJoinCondition joinCondition, JoinGraph joinGraph, SimpleConjunctiveQuery view) { SetAlias fromVariable = findVariable(joinCondition.getFromVariable(), view); SetAlias toVariable = findVariable(joinCondition.getToVariable(), view); joinGraph.addSuccessor(fromVariable, toVariable, joinCondition); if (!joinCondition.isMonodirectional()) { joinGraph.addSuccessor(toVariable, fromVariable, joinCondition); } }
//////////////// JOIN GRAPH CONSTRUCTION //////////////////// JoinGraph initializeJoinGraph(SimpleConjunctiveQuery view) { JoinGraph joinGraph = new JoinGraph(); for (SetAlias variable : view.getGenerators()) { joinGraph.addNode(variable); } for (VariableJoinCondition joinCondition : view.getJoinConditions()) { addJoinConditionToGraph(joinCondition, joinGraph, view); } return joinGraph; }
private void visitForPath( SetAlias variable, JoinGraph joinGraph, List<SetAlias> visitedVariables, List<JoinEdge> visitedEdges) { visitedVariables.add(variable); if (logger.isDebugEnabled()) logger.debug("Visiting graph searching for path from set: " + variable); List<JoinEdge> edges = joinGraph.getSuccessors().get(variable); for (JoinEdge edge : edges) { if (!visitedEdges.contains(edge)) { SetAlias successor = edge.getDestinationVariable(); if (!visitedVariables.contains(successor)) { visitedEdges.add(edge); visitForPath(successor, joinGraph, visitedVariables, visitedEdges); } } } }