Package lupos.engine.operators.singleinput

Examples of lupos.engine.operators.singleinput.Projection


      Join join = new Join();
      connection.connect(join);
      SeveralSucceedingOperators sso = new SeveralSucceedingOperators();
      sso.addSucceedingOperator(join, 0);
      FederatedQueryTrivialApproach federatedQuery = new FederatedQueryTrivialApproach(node);
      Projection projection = new Projection();
      projection.addProjectionElement(new Variable(((ASTVar)child0).getName()));
      Distinct distinct = new Distinct();
      projection.addSucceedingOperator(distinct);
      distinct.addSucceedingOperator(federatedQuery);
      sso.addSucceedingOperator(projection, 0);
      federatedQuery.addSucceedingOperator(join, 1);
      connection.setOperatorConnection(sso);
    }   
View Full Code Here


    if (!(op instanceof Projection)) {
      System.err
          .println("Replace has not Projection as direct successor or after its ReplaceLit => Correct RuleOptimizeReplaceByPat!!!");
      return false;
    } else {
      final Projection proj = (Projection) op;
      final Object[] projVars = proj.getProjectedVariables().toArray();
      final Item[] patItems = pat.getItems();
      for (int i = 0; i < patItems.length; i++) {
        // Only if a variable in TriplePattern is not projected later
        // (TP creates temporary tuples)
        if (patItems[i].isVariable()) {
View Full Code Here

    BasicOperator op = replaceVar.getSucceedingOperators().get(0)
        .getOperator();
    if (op instanceof ReplaceLit) {
      op = op.getSucceedingOperators().get(0).getOperator();
    }
    final Projection proj = (Projection) op;

    final LinkedList<Variable> replaceVarLeft = replaceVar
        .getSubstitutionsVariableLeft();
    final LinkedList<Variable> replaceVarRight = replaceVar
        .getSubstitutionsVariableRight();
    final Object[] projVars = proj.getProjectedVariables().toArray();
    final Item[] patItems = pat.getItems();

    Variable var;
    Variable newTripleVar;
View Full Code Here

public class RuleReplaceVarUnderProjection extends Rule {

  @Override
  protected void init() {
    final Projection projection = new Projection();
    final ReplaceVar replaceVar = new ReplaceVar();

    projection.setSucceedingOperator(new OperatorIDTuple(replaceVar, 0));
    replaceVar.setPrecedingOperator(projection);

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(projection, "projection");
    subGraphMap.put(replaceVar, "replaceVar");
View Full Code Here

  public Tuple<Collection<BasicOperator>, Collection<BasicOperator>> transformOperatorGraph(
      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final Collection<BasicOperator> deleted = new LinkedList<BasicOperator>();
    final Collection<BasicOperator> added = new LinkedList<BasicOperator>();
    final Projection projection = (Projection) mso.get("projection");
    final ReplaceVar replaceVar = (ReplaceVar) mso.get("replaceVar");

    // Clone ReplaceVar
    final ReplaceVar replaceVar_new = new ReplaceVar();
    replaceVar_new.setSubstitutionsVariableLeft(replaceVar
        .getSubstitutionsVariableLeft());
    replaceVar_new.setSubstitutionsVariableRight(replaceVar
        .getSubstitutionsVariableRight());

    replaceVar.removePrecedingOperator(projection);

    // Enhance projection variables by left tuple variables of ReplaceVar
    final LinkedList<Variable> vars = replaceVar
        .getSubstitutionsVariableLeft();
    for (int i = 0; i < vars.size(); i++) {
      if (!projection.getProjectedVariables().contains(vars.get(i))) {
        projection.addProjectionElement(vars.get(i));
      }
    }

    final LinkedList<BasicOperator> pres = (LinkedList<BasicOperator>) projection
        .getPrecedingOperators();
    final LinkedList<OperatorIDTuple> succs = (LinkedList<OperatorIDTuple>) replaceVar
        .getSucceedingOperators();

    BasicOperator pre;
    for (int i = 0; i < pres.size(); i++) {
      pre = pres.get(i);
      pre.addSucceedingOperator(new OperatorIDTuple(replaceVar_new, 0));
      pre.removeSucceedingOperator(projection);
    }

    replaceVar_new.setPrecedingOperators(pres);
    replaceVar_new
        .setSucceedingOperator(new OperatorIDTuple(projection, 0));

    projection.setPrecedingOperator(replaceVar_new);
    projection.setSucceedingOperators(succs);

    for (int i = 0; i < succs.size(); i++) {
      succs.get(i).getOperator().addPrecedingOperator(projection);
    }
View Full Code Here

    if (substVar > 0) {
      order.add(replaceVar);
      added.add(replaceVar);
    } else {
      final Projection p = new Projection();
      p.setIntersectionVariables(new HashSet<Variable>());
      p.setUnionVariables(p.getUnionVariables());
      order.add(p);
      added.add(p);
    }
    if (addBindingsVar.size() > 0) {
      final Iterator<Literal> lit_it = addBindingsLit.iterator();
View Full Code Here

    return replaceAfterPre;
  }

  private Projection getProjectionAfterReplace(final ReplaceVar replacePre,
      final BasicOperator pre) {
    final Projection projectionPre = new Projection();

    final Object[] unionVars = pre.getUnionVariables().toArray();
    final LinkedList<Variable> replaceVarsLeft = replacePre
        .getSubstitutionsVariableLeft();
    final LinkedList<Variable> replaceVarsRight = replacePre
        .getSubstitutionsVariableRight();

    // Let the tupel from the new ReplaceVar through
    for (int i = 0; i < replaceVarsLeft.size(); i++) {
      projectionPre.addProjectionElement(replaceVarsLeft.get(i));
    }

    // Let all UNION-Variable through, but not the ones which the new
    // ReplaceVar has replaced (right side)
    final LinkedList<Variable> projVars = new LinkedList<Variable>();
    for (int i = 0; i < unionVars.length; i++) {
      final Variable var = (Variable) unionVars[i];
      if (!replaceVarsRight.contains(var)) {
        projVars.add(var);
      }
    }

    // Add the calculated variables to the new projection
    for (int i = 0; i < projVars.size(); i++) {
      projectionPre.addProjectionElement(projVars.get(i));
    }

    return projectionPre;
  }
View Full Code Here

      pre = pres.get(i);
      indices.add(pre.getOperatorIDTuple(join).getId());
    }

    ReplaceVar rep;
    Projection projectionPre;
    for (int i = 0; i < pres.size(); i++) {
      pre = pres.get(i);

      // Calculate the new ReplaceVar which will be replaced between the
      // i-th precessor and the join
      rep = getReplaceAfterPre(replaceVar, originalClone, pre, join);

      // Calculate projection after precessor and new ReplaceVar
      projectionPre = getProjectionAfterReplace(rep, pre);

      added.add(rep);
      added.add(projectionPre);

      pre.setSucceedingOperator(new OperatorIDTuple(rep, 0));
      rep.setPrecedingOperator(pre);
      rep.setSucceedingOperator(new OperatorIDTuple(projectionPre, 0));

      projectionPre.setPrecedingOperator(rep);
      projectionPre.setSucceedingOperator(new OperatorIDTuple(join,
          indices.get(i)));
      join.setPrecedingOperator(projectionPre);
    }

    rootOperator.deleteParents();
View Full Code Here

      final Union union = new Union();

      final BasicOperator leftSide = this.zeroPath(node, graphConstraint, subject, object, subjectNode, objectNode);
      leftSide.addSucceedingOperator(new OperatorIDTuple(union,0));

      final Projection projection = new Projection();
      projection.addProjectionElement(subject);
      projection.addProjectionElement(object);
      if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
        projection.addProjectionElement((Variable)graphConstraint);
      }

      startingOperator.addSucceedingOperator(new OperatorIDTuple(union,1));

      union.addSucceedingOperator(new OperatorIDTuple(projection,0));
View Full Code Here

      // alternative way to evaluate (...)* without using the Closure and PathLengthZero operators!

      // Plus Operator
      final BasicOperator startingOperator = node.jjtGetChild(0).accept(this, connection, graphConstraint, subject, object, subjectNode, objectNode);

      final Projection projection = new Projection();
      projection.addProjectionElement(subject);
      projection.addProjectionElement(object);
      if(graphConstraint!=null && graphConstraint.isVariable() && !graphConstraint.equals(getItem(subjectNode)) && !graphConstraint.equals(getItem(objectNode))) {
        projection.addProjectionElement((Variable)graphConstraint);
      }

      final Union union = new Union();
      final InMemoryDistinct memoryDistinct = new InMemoryDistinct();
      try {
View Full Code Here

TOP

Related Classes of lupos.engine.operators.singleinput.Projection

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.