Package org.openrdf.query.algebra

Examples of org.openrdf.query.algebra.ProjectionElemList


       
    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


    // and these solutions are projected to subject-predicate-object bindings.
    // Finally, the spo-bindings are again filtered for duplicates.
    if (distinct) {
      // Create projection that removes all bindings that are not used in the
      // constructor
      ProjectionElemList projElemList = new ProjectionElemList();

      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

    throws VisitorException
  {
    TupleExpr result = (TupleExpr)data;

    Extension extension = new Extension();
    ProjectionElemList projElemList = new ProjectionElemList();

    for (ASTProjectionElem projElemNode : node.getProjectionElemList()) {
      ValueExpr valueExpr = (ValueExpr)projElemNode.getValueExpr().jjtAccept(this, null);

      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

    super.meet(node);
    if (node.getArg() instanceof SelectQuery) {
      SelectQuery query = (SelectQuery)node.getArg();
      Map<String, String> bindingNames = new HashMap<String, String>();
      List<SelectProjection> selection = new ArrayList<SelectProjection>();
      ProjectionElemList list = node.getProjectionElemList();
      for (ProjectionElem e : list.getElements()) {
        String source = e.getSourceName();
        String target = e.getTargetName();
        bindingNames.put(source, target);
        SelectProjection s = query.getSelectProjection(source);
        if (s != null) {
View Full Code Here

  public TupleExpr visit(ASTSelect node, Object data)
    throws VisitorException
  {
    TupleExpr result = (TupleExpr)data;

    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.isDistinct()) {
View Full Code Here

    // Create a Projection for each StatementPattern in the constructor
    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

      constraint = new Or(constraint, sameTerms.get(i));
    }

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

    if (currentBindings == null || nextProjectionIdx >= projections.size()) {
      currentBindings = iter.next();
      nextProjectionIdx = 0;
    }

    ProjectionElemList nextProjection = projections.get(nextProjectionIdx++);
    return ProjectionIterator.project(nextProjection, currentBindings, parentBindings);
  }
View Full Code Here

TOP

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

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.