Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.TupleExpr


  public Cursor<BindingSet> evaluate(QueryModel query, BindingSet bindings, boolean includeInferred)
    throws StoreException
  {
    triples.flush();
    TupleExpr tupleExpr;
    EvaluationStrategy strategy;
    strategy = factory.createRdbmsEvaluation(query);
    tupleExpr = optimizer.optimize(query, bindings, strategy);
    return strategy.evaluate(tupleExpr, EmptyBindingSet.getInstance());
  }
View Full Code Here


      super.meetOther(node);
      owned = null;
    }
    else {
      // no nested OwnedTupleExpr
      TupleExpr replacement = node.getArg().clone();
      node.replaceWith(replacement);
      replacement.visit(this);
    }
  }
View Full Code Here

    }

    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);
View Full Code Here

          // statement pattern
          joinOfAttributePatterns.addArg(attributePattern);
        }
      }

      TupleExpr expandedPattern = null;

      if (joinOfAttributePatterns.getNumberOfArguments() == 1) {
        expandedPattern = new LeftJoin(statementPattern, joinOfAttributePatterns.getArg(0));
      }
      else {
View Full Code Here

   * constraints in this graph pattern.
   *
   * @return A tuple expression for this graph pattern.
   */
  public TupleExpr buildTupleExpr() {
    TupleExpr result;

    if (requiredTEs.isEmpty()) {
      result = new SingletonSet();
    }
    else if (requiredTEs.size() == 1) {
View Full Code Here

        }

        // Reorder the (recursive) join arguments to a more optimal sequence
        List<TupleExpr> orderedJoinArgs = new ArrayList<TupleExpr>(joinArgs.size());
        while (!joinArgs.isEmpty()) {
          TupleExpr tupleExpr = selectNextTupleExpr(joinArgs, cardinalityMap, varsMap, varFreqMap,
              boundVars);

          joinArgs.remove(tupleExpr);
          orderedJoinArgs.add(tupleExpr);

          // Recursively optimize join arguments
          tupleExpr.visit(this);

          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 TupleExpr selectNextTupleExpr(List<TupleExpr> expressions,
        Map<TupleExpr, Double> cardinalityMap, Map<TupleExpr, List<Var>> varsMap,
        Map<Var, Integer> varFreqMap, Set<String> boundVars)
    {
      double lowestCardinality = Double.MAX_VALUE;
      TupleExpr result = null;

      for (TupleExpr tupleExpr : expressions) {
        // Calculate a score for this tuple expression
        double cardinality = getTupleExprCardinality(tupleExpr, cardinalityMap, varsMap, varFreqMap,
            boundVars);
View Full Code Here

  }

  private TupleExpr buildConstructor(TupleExpr bodyExpr, TupleExpr constructExpr, boolean explicit,
      boolean distinct)
  {
    TupleExpr result = bodyExpr;

    // Retrieve all StatementPattern's from the construct expression
    List<StatementPattern> statementPatterns = StatementPatternCollector.process(constructExpr);

    Set<Var> constructVars = getConstructVars(statementPatterns);
View Full Code Here

          else if (orNode.getNumberOfArguments() > 1) {
            constraints.add(orNode);
          }

          // remove the existing Filter
          TupleExpr filterArg = filter.getArg();
          filter.replaceWith(filterArg);

          // Insert a Union over the individual constraints, pushing it
          // down below other filters to avoid cloning them
          TupleExpr node = findNotFilter(filterArg);

          Union union = new Union();
          for (ValueExpr arg : constraints) {
            union.addArg(new Filter(node.clone(), arg));
          }

          node.replaceWith(union);

          // Enter recursion
          filter.getParentNode().visit(this);

          return;
View Full Code Here

      qc.jjtAccept(new ProjectionAliasProcessor(), null);
      qc.jjtAccept(new AnonymousVarGenerator(), null);

      // TODO: check use of unbound variables?

      TupleExpr tupleExpr = QueryModelBuilder.buildQueryModel(qc, new ValueFactoryImpl());

      ASTQuery queryNode = qc.getQuery();
      QueryModel query;
      if (queryNode instanceof ASTTupleQuery) {
        query = new TupleQueryModel(tupleExpr);
View Full Code Here

TOP

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

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.