@Override public boolean isSyntacticallyEquivalentTo(QueryNode node) { if (node instanceof UnionNode) { return projectedVariables.equals(((UnionNode)node).getVariables()); } return false; }
@Override public boolean isEquivalentTo(QueryNode queryNode) { if (!(queryNode instanceof UnionNode)) return false; return projectedVariables.equals(((UnionNode) queryNode).getVariables()); }
@Override public boolean isSyntacticallyEquivalentTo(QueryNode node) { if (node instanceof UnionNode) { return projectedVariables.equals(((UnionNode)node).getVariables()); } return false; }
@Override public UnionNode transform(UnionNode unionNode){ return iqFactory.createUnionNode(renameProjectedVars(unionNode.getVariables())); // return unionNode.clone(); }
@Override public UnionNode transform(UnionNode unionNode){ return iqFactory.createUnionNode(renameProjectedVars(unionNode.getVariables())); // return unionNode.clone(); }
@Override public void visit(UnionNode unionNode) { if (query.getChildren(unionNode).size() < 2) { throw new InvalidIntermediateQueryException("UNION node " + unionNode +" does not have at least 2 children node."); } ImmutableSet<Variable> unionProjectedVariables = unionNode.getVariables(); for (QueryNode child : query.getChildren(unionNode)) { ImmutableSet<Variable> childProjectedVariables = query.getVariables(child); if (!childProjectedVariables.containsAll(unionProjectedVariables)) { throw new InvalidIntermediateQueryException("This child " + child + " does not project all the variables " + "required by the UNION node (" + unionProjectedVariables + ")\n" + query); } } }
@Override public void visit(UnionNode unionNode) { if (query.getChildren(unionNode).size() < 2) { throw new InvalidIntermediateQueryException("UNION node " + unionNode +" does not have at least 2 children node."); } ImmutableSet<Variable> unionProjectedVariables = unionNode.getVariables(); for (QueryNode child : query.getChildren(unionNode)) { ImmutableSet<Variable> childProjectedVariables = query.getVariables(child); if (!childProjectedVariables.containsAll(unionProjectedVariables)) { throw new InvalidIntermediateQueryException("This child " + child + " does not project all the variables " + "required by the UNION node (" + unionProjectedVariables + ")\n" + query); } } }
Map<ImmutableCQ, IQTree> map = new HashMap<>(); ImmutableList<Variable> avs = ImmutableList.copyOf(rootNode.getVariables()); for (IQTree child : children) { ImmutableCQ cq;
freshHeadAtom = generateProjectionAtom(parentNode.get().getChildVariables()); } else { freshHeadAtom = generateProjectionAtom(((UnionNode) node).getVariables()); heads.add(new RuleHead(cn.getSubstitution(), freshHeadAtom, grandChild)); } else { ConstructionNode cn = iqFactory.createConstructionNode(((UnionNode) node).getVariables()); subQueryProjectionAtoms.put(cn, freshHeadAtom); heads.add(new RuleHead(cn.getSubstitution(), freshHeadAtom, Optional.ofNullable(child)));
DistinctVariableOnlyDataAtom freshHeadAtom = generateProjectionAtom(((UnionNode) node).getVariables()); heads.add(new RuleHead(cn.getSubstitution(), freshHeadAtom, grandChild)); } else { ConstructionNode cn = iqFactory.createConstructionNode(((UnionNode) node).getVariables()); subQueryProjectionAtoms.put(cn, freshHeadAtom); heads.add(new RuleHead(cn.getSubstitution(), freshHeadAtom, Optional.of(child)));