Java Code Examples for org.eclipse.rdf4j.query.algebra.Join#setLeftArg()

The following examples show how to use org.eclipse.rdf4j.query.algebra.Join#setLeftArg() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IterativeEvaluationOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void meet(Union union) {
	super.meet(union);

	TupleExpr leftArg = union.getLeftArg();
	TupleExpr rightArg = union.getRightArg();

	if (leftArg instanceof Join && rightArg instanceof Join) {
		Join leftJoinArg = (Join) leftArg;
		Join rightJoin = (Join) rightArg;

		if (leftJoinArg.getLeftArg().equals(rightJoin.getLeftArg())) {
			// factor out the left-most join argument
			Join newJoin = new Join();
			union.replaceWith(newJoin);
			newJoin.setLeftArg(leftJoinArg.getLeftArg());
			newJoin.setRightArg(union);
			union.setLeftArg(leftJoinArg.getRightArg());
			union.setRightArg(rightJoin.getRightArg());

			union.visit(this);
		}
	}
}
 
Example 2
Source File: BasicGroup.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private TupleExpr asJoin(Collection<TupleExpr> theList) {
	Join aJoin = new Join();

	if (theList.isEmpty()) {
		throw new RuntimeException("Can't have an empty or missing join.");
	} else if (theList.size() == 1) {
		return theList.iterator().next();
	}

	for (TupleExpr aExpr : theList) {
		if (aJoin.getLeftArg() == null) {
			aJoin.setLeftArg(aExpr);
		} else if (aJoin.getRightArg() == null) {
			aJoin.setRightArg(aExpr);
		} else {
			Join aNewJoin = new Join();

			aNewJoin.setLeftArg(aJoin);
			aNewJoin.setRightArg(aExpr);

			aJoin = aNewJoin;
		}
	}

	return aJoin;
}
 
Example 3
Source File: GeneralizedExternalProcessor.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void meet(Join queryNode) {

          // if query tree contains external tuples and they are not
          // positioned above statement pattern node
          // reposition
          if (this.extTuples.size() > 0 && !(queryNode.getRightArg() instanceof ExternalTupleSet)
                  && !(queryNode.getRightArg() instanceof BindingSetAssignment)) {

              if (queryNode.getLeftArg() instanceof ExternalTupleSet) {
                  QueryModelNode temp = queryNode.getLeftArg();
                  queryNode.setLeftArg(queryNode.getRightArg());
                  queryNode.setRightArg((TupleExpr)temp);
              } else {

                  QNodeExchanger qnev = new QNodeExchanger(queryNode.getRightArg(), this.extTuples);
                  queryNode.visit(qnev);
                  queryNode.replaceChildNode(queryNode.getRightArg(), qnev.getReplaced());
                  super.meet(queryNode);
              }
          } else {
              super.meet(queryNode);
          }

      }
 
Example 4
Source File: GeneralizedExternalProcessor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
		public void meet(Join node) {

            Set<QueryModelNode> eSet = getQNodes(node);

            if (eSet.containsAll(sSet) && !(node.getRightArg() instanceof BindingSetAssignment)) {

//                System.out.println("Eset is " + eSet + " and sSet is " + sSet);

                if (eSet.equals(sSet)) {
                    node.replaceWith(set);
                    indexPlaced = true;
                    return;
                } else {
                    if (node.getLeftArg() instanceof StatementPattern && sSet.size() == 1) {
                        if(sSet.contains(node.getLeftArg())) {
                            node.setLeftArg(set);
                            indexPlaced = true;
                        } else if(sSet.contains(node.getRightArg())) {
                            node.setRightArg(set);
                            indexPlaced = true;
                        } else {
                            return;
                        }
                    }
                    else {
                        super.meet(node);
                    }
                }
            } else if (eSet.containsAll(sSet)) {

                super.meet(node);

            } else {
                return;
            }

        }
 
Example 5
Source File: FilterFunctionOptimizer.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void meet(final Join node) {
    final QueryModelNode lNode = node.getLeftArg();
    if (lNode instanceof StatementPattern) {
        exchangeVar.replaceWith(lNode);
        node.setLeftArg(exchangeVar);
    } else {
        super.meet(node);
    }
}
 
Example 6
Source File: GeoEnabledFilterFunctionOptimizer.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void meet(final Join node) {
    final QueryModelNode lNode = node.getLeftArg();
    if (lNode instanceof StatementPattern) {
        exchangeVar.replaceWith(lNode);
        node.setLeftArg(exchangeVar);
    } else {
        super.meet(node);
    }
}