private ImmutableList<IQTree> extractChildrenToVisit(IQTree tree) { QueryNode node = tree.getRootNode(); if (node instanceof BinaryNonCommutativeOperatorNode) { if (node instanceof LeftJoinNode) { return ImmutableList.of(((BinaryNonCommutativeIQTree)tree).getLeftChild()); } /* * Not supported BinaryNonCommutativeOperatorNode: we ignore them */ else { return ImmutableList.of(); } } else { return tree.getChildren(); } }
private IQTree liftLJJoin(BinaryNonCommutativeIQTree queryTree, IQTree newLeftChild, IQTree newRightChild, VariableGenerator variableGenerator) { LeftJoinNode leftJoinNode = (LeftJoinNode) queryTree.getRootNode(); BinaryNonCommutativeIQTree newQueryTree = newLeftChild.equals(queryTree.getLeftChild()) && newRightChild.equals(queryTree.getRightChild()) ? queryTree : iqFactory.createBinaryNonCommutativeIQTree(leftJoinNode, newLeftChild, newRightChild); return extractCandidateVariables(queryTree, leftJoinNode.getOptionalFilterCondition(), ImmutableList.of(newLeftChild, newRightChild)) .filter(v -> newLeftChild.getVariables().contains(v)) .map(newQueryTree::liftIncompatibleDefinitions) .filter(t -> !t.equals(queryTree)) .findFirst() .orElse(newQueryTree) .liftBinding(variableGenerator); }
private IQTree liftBinaryNonCommutative(BinaryNonCommutativeIQTree queryTree, VariableGenerator variableGenerator) { BinaryNonCommutativeOperatorNode root = queryTree.getRootNode(); IQTree newLeftChild = liftTree(queryTree.getLeftChild(), variableGenerator); IQTree newRightChild = liftTree(queryTree.getRightChild(), variableGenerator); if (root instanceof LeftJoinNode) { return liftLJJoin(queryTree, newLeftChild, newRightChild, variableGenerator); } else return newLeftChild.equals(queryTree.getLeftChild()) && newRightChild.equals(queryTree.getRightChild()) ? queryTree : iqFactory.createBinaryNonCommutativeIQTree(root, newLeftChild, newRightChild); }
BinaryNonCommutativeIQTree ljTree = (BinaryNonCommutativeIQTree) tree; List<Function> atomsListLeft = getAtomFrom(ljTree.getLeftChild(), heads, subQueryProjectionAtoms, true); List<Function> atomsListRight = getAtomFrom(ljTree.getRightChild(), heads, subQueryProjectionAtoms, true);