protected ArbitraryLengthPathNode arbitartyLengthPropertyPath(TermNode left, TermNode right, HelperFlag card, JoinGroupNode joinGroupNode) { assert leftVar != null; assert rightVar != null; ArbitraryLengthPathNode rslt = new ArbitraryLengthPathNode(left, right, leftVar, rightVar, PathMod.ONE_OR_MORE); card.apply(rslt); rslt.setArg(0, joinGroupNode); leftVar = null; rightVar = null; return rslt; }
/** * Set the edge var and middle term. Only used by the ALP service when * projecting edges. */ public void setEdgeVar(final VarNode edgeVar, final TermNode middle) { setProperty(Annotations.MIDDLE_TERM, middle); setProperty(Annotations.EDGE_VAR, edgeVar); }
/** * Return the variables bound by the path - i.e. what this node will * attempt to bind when run. */ public Set<IVariable<?>> getDefinitelyProducedBindings() { final Set<IVariable<?>> producedBindings = new LinkedHashSet<IVariable<?>>(); addVar(left(), producedBindings, true); addVar(right(), producedBindings, true); final VarNode edgeVar = edgeVar(); if (edgeVar != null) { addProducedBinding(edgeVar, producedBindings); } return producedBindings; }
/** * Return the variables bound by the path - i.e. what this node will * attempt to bind when run. */ public Set<IVariable<?>> getMaybeProducedBindings() { final Set<IVariable<?>> producedBindings = getDefinitelyProducedBindings(); for (StatementPatternNode sp : subgroup().getStatementPatterns()) { addProducedBinding(sp.s(), producedBindings); addProducedBinding(sp.p(), producedBindings); addProducedBinding(sp.o(), producedBindings); addProducedBinding(sp.c(), producedBindings); } return producedBindings; }
/** * Test interface implementation for ALP nodes. */ @SuppressWarnings("serial") public void testSimpleALPNode() { final ArbitraryLengthPathNode alpNode = (ArbitraryLengthPathNode) new Helper() {{ tmp = arbitartyLengthPropertyPath( varNode(x), constantNode(b), HelperFlag.ZERO_OR_MORE, joinGroupNode( statementPatternNode( leftVar(), constantNode(c), rightVar(), 26))); }}.getTmp(); final Set<IVariable<?>> requiredBoundAlpNode = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBoundAlpNode = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; // dummy sa object final StaticAnalysis sa = new StaticAnalysis(new QueryRoot(QueryType.SELECT), null); assertEquals(requiredBoundAlpNode, alpNode.getRequiredBound(sa)); assertEquals(desiredBoundAlpNode, alpNode.getDesiredBound(sa)); }
final ArbitraryLengthPathNode alpNode = new ArbitraryLengthPathNode( left, right, tVarLeft, tVarRight, alpNode.setEdgeVar(edgeVar, middle); alpNode.subgroup().addChild(pathExpr); for (@SuppressWarnings("rawtypes") GroupMemberNodeBase child : subgroup.getChildren(GroupMemberNodeBase.class)) { group2.addChild((IGroupMemberNode) child.clone()); } else { alpNode.subgroup().addChild(child); alpNode.setDropVars(dropVars);
alpNode = new ArbitraryLengthPathNode(ppInfo.s, ppInfo.o, tVarLeft, tVarRight, mod); final String pipelinedHashJoinHint = queryHints==null ? null : queryHints.getProperty(QueryHints.PIPELINED_HASH_JOIN); if (pipelinedHashJoinHint!=null) { alpNode.setQueryHint( QueryHints.PIPELINED_HASH_JOIN, pipelinedHashJoinHint); group = alpNode.subgroup();
(ArbitraryLengthPathNode) child; final long cardinality = alp.getEstimatedCardinality(null); alp.setProperty(Annotations.ESTIMATED_CARDINALITY, cardinality);
final Set<IVariable<?>> used = getDefinitelyProducedBindings(); for (StatementPatternNode sp : subgroup().getStatementPatterns()) { addUsedVar(sp.s(), used); addUsedVar(sp.p(), used); addUsedVar(sp.o(), used); addUsedVar(sp.c(), used); for (FilterNode filter : sp.getAttachedJoinFilters()) { final Iterator<BOp> it = BOpUtility.preOrderIteratorWithAnnotations(filter); final BOp bop = it.next(); if (bop instanceof TermNode) { addUsedVar((TermNode) bop, used); for (FilterNode filter : subgroup().getChildren(FilterNode.class)) { final Iterator<BOp> it = BOpUtility.preOrderIteratorWithAnnotations(filter); while (it.hasNext()) { final BOp bop = it.next(); if (bop instanceof TermNode) { addUsedVar((TermNode) bop, used);
private void addProducedBinding(final TermNode t, final Set<IVariable<?>> producedBindings) { addVar(t, producedBindings, false); }
protected void addNegateds( final GraphPatternGroup<? extends IGroupMemberNode> group, final ArrayList<ConstantNode> constants, final PropertyPathInfo ppInfo, final ArbitraryLengthPathNode alpNode, final PropertyPathNode ppNode) { final VarNode p = anonVar(); if (alpNode != null) { alpNode.addDropVar(p); } final StatementPatternNode sp = ppInfo.toStatementPattern(p); final TermNode[] args = new TermNode[constants.size()+1]; args[0] = p; System.arraycopy(constants.toArray(new ConstantNode[constants.size()]), 0, args, 1, constants.size()); final FunctionNode function = new FunctionNode( FunctionRegistry.NOT_IN, null, args ); final FilterNode filter = new FilterNode(function); group.addArg(getPositionOfNodeInGroup(ppNode, group),sp); group.addArg(getPositionOfNodeInGroup(ppNode, group),filter); }
/** * Test interface implementation for ALP nodes. */ @SuppressWarnings("serial") public void testSimpleALPNode() { final ArbitraryLengthPathNode alpNode = (ArbitraryLengthPathNode) new Helper() {{ tmp = arbitartyLengthPropertyPath( varNode(x), constantNode(b), HelperFlag.ZERO_OR_MORE, joinGroupNode( statementPatternNode( leftVar(), constantNode(c), rightVar(), 26))); }}.getTmp(); final Set<IVariable<?>> requiredBoundAlpNode = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBoundAlpNode = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; // dummy sa object final StaticAnalysis sa = new StaticAnalysis(new QueryRoot(QueryType.SELECT), null); assertEquals(requiredBoundAlpNode, alpNode.getRequiredBound(sa)); assertEquals(desiredBoundAlpNode, alpNode.getDesiredBound(sa)); }
final ArbitraryLengthPathNode alpNode = new ArbitraryLengthPathNode( left, right, tVarLeft, tVarRight, alpNode.setEdgeVar(edgeVar, middle); alpNode.subgroup().addChild(pathExpr); for (@SuppressWarnings("rawtypes") GroupMemberNodeBase child : subgroup.getChildren(GroupMemberNodeBase.class)) { group2.addChild((IGroupMemberNode) child.clone()); } else { alpNode.subgroup().addChild(child); alpNode.setDropVars(dropVars);
alpNode = new ArbitraryLengthPathNode(ppInfo.s, ppInfo.o, tVarLeft, tVarRight, mod); final String pipelinedHashJoinHint = queryHints==null ? null : queryHints.getProperty(QueryHints.PIPELINED_HASH_JOIN); if (pipelinedHashJoinHint!=null) { alpNode.setQueryHint( QueryHints.PIPELINED_HASH_JOIN, pipelinedHashJoinHint); group = alpNode.subgroup();
(ArbitraryLengthPathNode) child; final long cardinality = alp.getEstimatedCardinality(null); alp.setProperty(Annotations.ESTIMATED_CARDINALITY, cardinality);
/** * Return the variables bound by the path - i.e. what this node will * attempt to bind when run. */ public Set<IVariable<?>> getMaybeProducedBindings() { final Set<IVariable<?>> producedBindings = getDefinitelyProducedBindings(); for (StatementPatternNode sp : subgroup().getStatementPatterns()) { addProducedBinding(sp.s(), producedBindings); addProducedBinding(sp.p(), producedBindings); addProducedBinding(sp.o(), producedBindings); addProducedBinding(sp.c(), producedBindings); } return producedBindings; }
final Set<IVariable<?>> used = getDefinitelyProducedBindings(); for (StatementPatternNode sp : subgroup().getStatementPatterns()) { addUsedVar(sp.s(), used); addUsedVar(sp.p(), used); addUsedVar(sp.o(), used); addUsedVar(sp.c(), used); for (FilterNode filter : sp.getAttachedJoinFilters()) { final Iterator<BOp> it = BOpUtility.preOrderIteratorWithAnnotations(filter); final BOp bop = it.next(); if (bop instanceof TermNode) { addUsedVar((TermNode) bop, used); for (FilterNode filter : subgroup().getChildren(FilterNode.class)) { final Iterator<BOp> it = BOpUtility.preOrderIteratorWithAnnotations(filter); while (it.hasNext()) { final BOp bop = it.next(); if (bop instanceof TermNode) { addUsedVar((TermNode) bop, used);
private void addUsedVar(final TermNode t, final Set<IVariable<?>> vars) { addVar(t, vars, true); }
protected void addNegateds( final GraphPatternGroup<? extends IGroupMemberNode> group, final ArrayList<ConstantNode> constants, final PropertyPathInfo ppInfo, final ArbitraryLengthPathNode alpNode, final PropertyPathNode ppNode) { final VarNode p = anonVar(); if (alpNode != null) { alpNode.addDropVar(p); } final StatementPatternNode sp = ppInfo.toStatementPattern(p); final TermNode[] args = new TermNode[constants.size()+1]; args[0] = p; System.arraycopy(constants.toArray(new ConstantNode[constants.size()]), 0, args, 1, constants.size()); final FunctionNode function = new FunctionNode( FunctionRegistry.NOT_IN, null, args ); final FilterNode filter = new FilterNode(function); group.addArg(getPositionOfNodeInGroup(ppNode, group),sp); group.addArg(getPositionOfNodeInGroup(ppNode, group),filter); }
@SuppressWarnings("serial") public void testComplexALPNode() { final ArbitraryLengthPathNode alpNode = (ArbitraryLengthPathNode) new Helper() {{ tmp = arbitartyLengthPropertyPath( varNode(x), constantNode(b), HelperFlag.ZERO_OR_MORE, joinGroupNode( statementPatternNode(leftVar(), constantNode(c), varNode(y)), statementPatternNode(varNode(y), constantNode(d), rightVar()) )); }}.getTmp(); final Set<IVariable<?>> requiredBoundAlpNode = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBoundAlpNode = new HashSet<IVariable<?>>() {{ add(Var.var("x")); add(Var.var("y")); }}; // dummy sa object final StaticAnalysis sa = new StaticAnalysis(new QueryRoot(QueryType.SELECT), null); assertEquals(requiredBoundAlpNode, alpNode.getRequiredBound(sa)); assertEquals(desiredBoundAlpNode, alpNode.getDesiredBound(sa)); }