Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.Join


      Set<SignedConnection> joinOwners = exprOwnerMap.remove(iter.next());
      while (iter.hasNext()) {
        joinOwners.retainAll(exprOwnerMap.remove(iter.next()));
      }

      Join localJoin = new Join(joinArgs);
      exprOwnerMap.put(localJoin, joinOwners);
    }

    // Join any join arguments that have the same, unique owner
    for (Set<TupleExpr> joinArgs : getColocatedJoins(exprOwnerMap)) {
      // FIXME: handle args that are not connected
      Set<SignedConnection> owners = null;
      for (TupleExpr joinArg : joinArgs) {
        owners = exprOwnerMap.remove(joinArg);
        assert owners.size() == 1;
      }

      Join localJoin = new Join(joinArgs);
      exprOwnerMap.put(localJoin, owners);
    }

    Join replacement = new Join();

    for (Map.Entry<TupleExpr, Set<SignedConnection>> entry : exprOwnerMap.entrySet()) {
      TupleExpr joinArg = entry.getKey();
      Set<SignedConnection> owners = entry.getValue();

      if (owners.isEmpty()) {
        // No results for this expression and thus for the entire join
        join.replaceWith(new EmptySet());
        return;
      }
      else if (owners.size() == 1) {
        SignedConnection owner = owners.iterator().next();
        replacement.addArg(new OwnedTupleExpr(owner, joinArg));
      }
      else if (joinArg instanceof Join || distinct) {
        // Local join with multiple owners or distinct federation members
        Union union = new Union();
        for (SignedConnection owner : owners) {
          union.addArg(new OwnedTupleExpr(owner, joinArg.clone()));
        }
        replacement.addArg(union);
      }
      else {
        replacement.addArg(joinArg);
      }
    }

    join.replaceWith(replacement);
    // addOwners(join, exprOwnerMap, localExprs);
View Full Code Here


      if (attributes == null || attributes.size() == 0) {
        return;
      }

      // join of the attribute match expressions.
      Join joinOfAttributePatterns = new Join();

      URI inheritanceProp = getInheritanceProperty();
      Var inheritPredVar = new Var("-acl_inherit_pred", inheritanceProp);

      int i = 0;

      List<Var> attributeVars = new ArrayList<Var>();
      for (URI attribute : attributes) {
        Var attributeVar = new Var("-acl_attr_" + i++);
        attributeVars.add(attributeVar);

        Var attributePredVar = new Var("-acl_attr_pred_" + i, attribute);

        // SP(?subject, accessAttr_i, ?accessAttrValue_i)
        StatementPattern attributePattern = new StatementPattern(subjectVar, attributePredVar,
            attributeVar);

        if (inheritanceProp != null) {
          // create a union expression for this attribute.
          Union union = new Union();
          union.addArg(attributePattern);

          // the join for checking if the access attribute is inherited.
          Join inheritJoin = new Join();
          Var inheritVar = new Var("-acl_inherited_value" + i);
          // SP (?subject, inheritProp, ?S_i)
          StatementPattern inheritPattern = new StatementPattern(subjectVar, inheritPredVar, inheritVar);
          inheritJoin.addArg(inheritPattern);
          // SP (?S_i, accessAttr_i, ?accessAttrValue_i)
          StatementPattern inheritAttrPattern = new StatementPattern(inheritVar, attributePredVar,
              attributeVar);
          inheritJoin.addArg(inheritAttrPattern);

          union.addArg(inheritJoin);

          joinOfAttributePatterns.addArg(union);
        }
View Full Code Here

    }
    else if (requiredTEs.size() == 1) {
      result = requiredTEs.get(0);
    }
    else {
      result = new Join(requiredTEs);
    }

    for (TupleExpr optTE : optionalTEs) {
      result = new LeftJoin(result, optTE);
    }
View Full Code Here

          boundVars.addAll(tupleExpr.getBindingNames());
        }

        // Build new join hierarchy
        TupleExpr replacement = new Join(orderedJoinArgs);

        // Replace old join hierarchy
        node.replaceWith(replacement);
      }
      finally {
View Full Code Here

      }
    }

    protected <L extends List<TupleExpr>> L getJoinArgs(TupleExpr tupleExpr, L joinArgs) {
      if (tupleExpr instanceof Join) {
        Join join = (Join)tupleExpr;
        for (TupleExpr arg : join.getArgs()) {
          getJoinArgs(arg, joinArgs);
        }
      }
      else {
        joinArgs.add(tupleExpr);
View Full Code Here

    }
    else if (requiredTEs.size() == 1) {
      result = requiredTEs.get(0);
    }
    else {
      result = new Join(requiredTEs);
    }

    for (OptionalTupleExpr optTE : optionalTEs) {
      if (optTE.hasConstraint()) {
        result = new LeftJoin(result, optTE.getTupleExpr(), optTE.getConstraint());
View Full Code Here

    if (result == null) {
      result = sp;
    }
    else {
      result = new Join(result, sp);
    }

    List<SameTerm> sameTerms = new ArrayList<SameTerm>(2 * node.jjtGetNumChildren());

    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
View Full Code Here

    public TupleExpr joinTupleExpressions() {
        Iterator<TupleExpr> i = _tupleExprs.iterator();
        TupleExpr result = i.hasNext() ? i.next() : null;
       
        while (i.hasNext()) {
            result = new Join(result, i.next());
        }
        return result;
    }
View Full Code Here

    }
    else {
      result = requiredTEs.get(0);

      for (int i = 1; i < requiredTEs.size(); i++) {
        result = new Join(result, requiredTEs.get(i));
      }
    }

    for (OptionalTupleExpr optTE : optionalTEs) {
      if (optTE.hasConstraint()) {
View Full Code Here

      joinArgs = sortExpressions(joinArgs, new HashSet<String>());

      // Build new join hierarchy
      TupleExpr replacement = joinArgs.get(0);
      for (int i = 1; i < joinArgs.size(); i++) {
        replacement = new Join(replacement, joinArgs.get(i));
      }

      // Replace old join hierarchy
      node.replaceWith(replacement);
    }
View Full Code Here

TOP

Related Classes of org.openrdf.query.algebra.Join

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.