Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.ProjectionElem


      for (Var var : constructVars) {
        // Ignore anonymous and constant vars, these will be handled after
        // the distinct
        if (!var.isAnonymous() && !var.hasValue()) {
          projElemList.addElement(new ProjectionElem(var.getName()));
        }
      }

      result = new Projection(result, projElemList);

      // Filter the duplicates from these projected bindings
      result = new Distinct(result);
    }

    // Create BNodeGenerator's for all anonymous variables
    Map<Var, ExtensionElem> extElemMap = new HashMap<Var, ExtensionElem>();

    for (Var var : constructVars) {
      if (var.isAnonymous() && !extElemMap.containsKey(var)) {
        ValueExpr valueExpr = null;

        if (var.hasValue()) {
          valueExpr = new ValueConstant(var.getValue());
        }
        else if (explicit) {
          // only generate bnodes in case of an explicit constructor
          valueExpr = new BNodeGenerator();
        }

        if (valueExpr != null) {
          extElemMap.put(var, new ExtensionElem(valueExpr, var.getName()));
        }
      }
    }

    if (!extElemMap.isEmpty()) {
      result = new Extension(result, extElemMap.values());
    }

    // Create a Projection for each StatementPattern in the constructor
    List<ProjectionElemList> projections = new ArrayList<ProjectionElemList>();

    for (StatementPattern sp : statementPatterns) {
      ProjectionElemList projElemList = new ProjectionElemList();

      projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject"));
      projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate"));
      projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));

      projections.add(projElemList);
    }

    if (projections.size() == 1) {
View Full Code Here


      String alias = projElemNode.getAlias();
      if (alias != null) {
        // aliased projection element
        extension.addElement(new ExtensionElem(valueExpr, alias));
        projElemList.addElement(new ProjectionElem(alias));
      }
      else if (valueExpr instanceof Var) {
        // unaliased variable
        Var projVar = (Var)valueExpr;
        projElemList.addElement(new ProjectionElem(projVar.getName()));
      }
      else {
        throw new IllegalStateException("required alias for non-Var projection elements not found");
      }
    }
View Full Code Here

    ProjectionElemList projElemList = new ProjectionElemList();

    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      Var projVar = (Var)node.jjtGetChild(i).jjtAccept(this, null);
      projElemList.addElement(new ProjectionElem(projVar.getName()));
    }

    result = new Projection(result, projElemList);

    if (node.isReduced()) {
View Full Code Here

    List<ProjectionElemList> projList = new ArrayList<ProjectionElemList>();

    for (StatementPattern sp : statementPatterns) {
      ProjectionElemList projElemList = new ProjectionElemList();

      projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject"));
      projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate"));
      projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));

      projList.add(projElemList);
    }

    if (projList.size() == 1) {
View Full Code Here

    ValueExpr constraint = new Or(sameTerms);

    result = new Filter(result, constraint);

    ProjectionElemList projElemList = new ProjectionElemList();
    projElemList.addElement(new ProjectionElem(subjVar.getName(), "subject"));
    projElemList.addElement(new ProjectionElem(predVar.getName(), "predicate"));
    projElemList.addElement(new ProjectionElem(objVar.getName(), "object"));
    result = new Projection(result, projElemList);

    return new Reduced(result);
  }
View Full Code Here

                  Group2 group = new Group2(_builder.makeFilterTupleExpr());
                  group.addGroupElement(new GroupElem(_countVar.getName(), new Count(_itemVar)));
                  group.addGroupBindingName(_valueVar.getName());
                 
                  ProjectionElemList projectionElements = new ProjectionElemList();
                  projectionElements.addElement(new ProjectionElem(_valueVar.getName()));
                  projectionElements.addElement(new ProjectionElem(_countVar.getName()));
                 
                  Projection projection = new Projection(group, projectionElements);
                  Order order = "value".equals(_sortMode) ?
                      new Order(projection, new OrderElem(_valueVar, "forward".equals(_sortDirection))) :
                      new Order(projection, new OrderElem(_countVar, !"forward".equals(_sortDirection)));
View Full Code Here

                tupleExprs :
                new Filter(tupleExprs, conditions);
    }
   
    public Projection makeProjection(Var var) {
        return makeProjection(new ProjectionElemList(new ProjectionElem(var.getName())));
    }
View Full Code Here

            projectionElements
        );
    }
   
    public TupleQuery makeTupleQuery(Var var, SailRepositoryConnection connection) {
        return makeTupleQuery(new ProjectionElemList(new ProjectionElem(var.getName())), connection);
    }
View Full Code Here

    ExpressionResult expressionResult = computeOutputOnItem(database, builder, valueVar);
        if (expressionResult.valueExpr instanceof Var) {
          Var resultVar = (Var) expressionResult.valueExpr;
         
            ProjectionElemList projectionElements = new ProjectionElemList();
            projectionElements.addElement(new ProjectionElem(resultVar.getName()));
           
            TupleExpr t = builder.makeFilterTupleExpr();
            if (t == null) {
              // TODO[dfhuynh]: This happens if the expression is just "value". I'm not sure what to do here.
              return null;
View Full Code Here

      for (Var var : constructVars) {
        // Ignore anonymous and constant vars, these will be handled after
        // the distinct
        if (!var.isAnonymous() && !var.hasValue()) {
          projElemList.addElement(new ProjectionElem(var.getName()));
        }
      }

      result = new Projection(result, projElemList);

      // Filter the duplicates from these projected bindings
      result = new Distinct(result);
    }

    // Create BNodeGenerator's for all anonymous variables
    Map<Var, ExtensionElem> extElemMap = new HashMap<Var, ExtensionElem>();

    for (Var var : constructVars) {
      if (var.isAnonymous() && !extElemMap.containsKey(var)) {
        ValueExpr valueExpr = null;

        if (var.hasValue()) {
          valueExpr = new ValueConstant(var.getValue());
        }
        else if (explicit) {
          // only generate bnodes in case of an explicit constructor
          valueExpr = new BNodeGenerator();
        }

        if (valueExpr != null) {
          extElemMap.put(var, new ExtensionElem(valueExpr, var.getName()));
        }
      }
    }

    if (!extElemMap.isEmpty()) {
      result = new Extension(result, extElemMap.values());
    }

    // Create a Projection for each StatementPattern in the constructor
    List<ProjectionElemList> projections = new ArrayList<ProjectionElemList>();

    for (StatementPattern sp : statementPatterns) {
      ProjectionElemList projElemList = new ProjectionElemList();

      projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject"));
      projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate"));
      projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));

      projections.add(projElemList);
    }

    if (projections.size() == 1) {
View Full Code Here

TOP

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

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.