private NodeCentricOptimizationResults<ConstructionNode> deleteConstructionNodeChain(IntermediateQuery query, QueryTreeComponent treeComponent, ConstructionNode focusNode, QueryNode childSubtreeRoot) { IntermediateQuery snapshot = query.createSnapshot(); treeComponent.replaceSubTree(focusNode, childSubtreeRoot); treeComponent.addSubTree(snapshot, childSubtreeRoot, childSubtreeRoot); return new NodeCentricOptimizationResultsImpl(query, Optional.of(childSubtreeRoot)); }
private NodeCentricOptimizationResults<ConstructionNode> deleteConstructionNodeChain(IntermediateQuery query, QueryTreeComponent treeComponent, ConstructionNode focusNode, QueryNode childSubtreeRoot) { IntermediateQuery snapshot = query.createSnapshot(); treeComponent.replaceSubTree(focusNode, childSubtreeRoot); treeComponent.addSubTree(snapshot, childSubtreeRoot, childSubtreeRoot); return new NodeCentricOptimizationResultsImpl(query, Optional.of(childSubtreeRoot)); }
private NodeCentricOptimizationResults<ConstructionNode> flattenConstructionNodeChain(IntermediateQuery query, QueryTreeComponent treeComponent, ConstructionNode focusNode, QueryNode childSubtreeRoot) { IntermediateQuery snapshot = query.createSnapshot(); ConstructionNode replacingNode = iqFactory.createConstructionNode( focusNode.getVariables(), focusNode.getSubstitution()); treeComponent.replaceSubTree(focusNode, replacingNode); treeComponent.addChild(replacingNode, childSubtreeRoot, Optional.empty(), false); treeComponent.addSubTree(snapshot, childSubtreeRoot, childSubtreeRoot); return new NodeCentricOptimizationResultsImpl<>(query, replacingNode); } }
/** * Replace the child subtrees of the focus node **/ @Override public NodeCentricOptimizationResults<UnionNode> apply(FlattenUnionProposal proposal, IntermediateQuery query, QueryTreeComponent treeComponent) throws InvalidQueryOptimizationProposalException, EmptyQueryException { UnionNode focusNode = proposal.getFocusNode(); IntermediateQuery snapShot = query.createSnapshot(); query.getChildren(focusNode).stream() .forEach(n -> treeComponent.removeSubTree(n)); ImmutableSet<QueryNode> subqueryRoots = proposal.getSubqueryRoots(); subqueryRoots.forEach(n -> treeComponent.addChild( focusNode, n, Optional.empty(), false )); subqueryRoots.forEach(n -> treeComponent.addSubTree( snapShot, n, n )); return new NodeCentricOptimizationResultsImpl<>(query, focusNode); }
/** * Replace the child subtrees of the focus node **/ @Override public NodeCentricOptimizationResults<UnionNode> apply(FlattenUnionProposal proposal, IntermediateQuery query, QueryTreeComponent treeComponent) throws InvalidQueryOptimizationProposalException, EmptyQueryException { UnionNode focusNode = proposal.getFocusNode(); IntermediateQuery snapShot = query.createSnapshot(); query.getChildren(focusNode).stream() .forEach(n -> treeComponent.removeSubTree(n)); ImmutableSet<QueryNode> subqueryRoots = proposal.getSubqueryRoots(); subqueryRoots.forEach(n -> treeComponent.addChild( focusNode, n, Optional.empty(), false )); subqueryRoots.forEach(n -> treeComponent.addSubTree( snapShot, n, n )); return new NodeCentricOptimizationResultsImpl<>(query, focusNode); }
private NodeCentricOptimizationResults<ConstructionNode> flattenConstructionNodeChain(IntermediateQuery query, QueryTreeComponent treeComponent, ConstructionNode focusNode, QueryNode childSubtreeRoot, Optional<ImmutableQueryModifiers> modifiers) { IntermediateQuery snapshot = query.createSnapshot(); ConstructionNode replacingNode = iqFactory.createConstructionNode( focusNode.getVariables(), focusNode.getSubstitution(), modifiers ); treeComponent.replaceSubTree(focusNode, replacingNode); treeComponent.addChild(replacingNode, childSubtreeRoot, Optional.empty(), false); treeComponent.addSubTree(snapshot, childSubtreeRoot, childSubtreeRoot); return new NodeCentricOptimizationResultsImpl<>(query, replacingNode); } }
private UnionNode liftUnionNode(UnionLiftProposal proposal, IntermediateQuery query, QueryTreeComponent treeComponent) { QueryNode targetNode = proposal.getTargetNode(); UnionNode focusNode = proposal.getFocusNode(); UnionNode newTopUnionNode = iqFactory.createUnionNode(query.getVariables(targetNode)); IntermediateQuery querySnapshot = query.createSnapshot(); treeComponent.replaceSubTree(targetNode, newTopUnionNode); querySnapshot.getChildren(focusNode) .forEach(c -> appendUnionChildBranch(c, focusNode, targetNode, newTopUnionNode, query, querySnapshot, treeComponent)); return newTopUnionNode; }
private UnionNode liftUnionNode(UnionLiftProposal proposal, IntermediateQuery query, QueryTreeComponent treeComponent) { QueryNode targetNode = proposal.getTargetNode(); UnionNode focusNode = proposal.getFocusNode(); UnionNode newTopUnionNode = iqFactory.createUnionNode(query.getVariables(targetNode)); IntermediateQuery querySnapshot = query.createSnapshot(); treeComponent.replaceSubTree(targetNode, newTopUnionNode); querySnapshot.getChildren(focusNode) .forEach(c -> appendUnionChildBranch(c, focusNode, targetNode, newTopUnionNode, query, querySnapshot, treeComponent)); return newTopUnionNode; }