Package lupos.engine.operators.singleinput

Examples of lupos.engine.operators.singleinput.Projection


  }

  public static void main(final String[] args) {
    // The whole graph:
    final Operator wa = new Join();
    final Operator wb = new Projection();
    wa.setSucceedingOperator(new OperatorIDTuple(wb, 0));
    wb.setPrecedingOperator(wa);

    // Define left side of rule
    final Operator a = new Join();
    final Operator b = new Projection();
    a.setSucceedingOperator(new OperatorIDTuple(b, -1));
    b.setPrecedingOperator(a);
    final Map<BasicOperator, String> subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(a, "a");
    subGraphMap.put(b, "b");

    final Map<String, BasicOperator> result = checkSubGraph(wa,
View Full Code Here


public class RuleReplaceLitOverProjection extends Rule {

  @Override
  protected void init() {
    final ReplaceLit replaceLit = new ReplaceLit();
    final Projection projection = new Projection();

    replaceLit.setSucceedingOperator(new OperatorIDTuple(projection, -1));
    projection.setPrecedingOperator(replaceLit);

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

    startNode = replaceLit;
  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final Projection projection = (Projection) mso.get("projection");
    if (projection.getPrecedingOperators().size() == 1)
      return true;
    else
      return false;
  }
View Full Code Here

  @Override
  public Tuple<Collection<BasicOperator>, Collection<BasicOperator>> transformOperatorGraph(
      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final ReplaceLit replaceLit = (ReplaceLit) mso.get("replaceLit");
    final Projection projection = (Projection) mso.get("projection");

    final Object[] projectionVars = projection.getProjectedVariables()
        .toArray();
    final LinkedList<Variable> replaceLitLeft = replaceLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> replaceLitRight = replaceLit
        .getSubstitutionsLiteralRight();
    Variable var;
    Literal lit;
    // Delete all not projected Tupels from ReplaceLit
    for (int i = 0; i < replaceLitLeft.size(); i++) {
      var = replaceLitLeft.get(i);
      if (!arrayContains(projectionVars, var)) {
        lit = replaceLitRight.get(i);
        replaceLit.removeSubstitution(var, lit);
      }
    }

    final LinkedList<BasicOperator> pres = (LinkedList<BasicOperator>) replaceLit
        .getPrecedingOperators();
    final LinkedList<OperatorIDTuple> succs = (LinkedList<OperatorIDTuple>) projection
        .getSucceedingOperators();
    final int index = replaceLit.getOperatorIDTuple(projection).getId();

    BasicOperator pre;
    // Connect the ReplaceLit precessors directly to the Projection
    for (int i = pres.size() - 1; i >= 0; i--) {
      pre = pres.get(i);
      projection.addPrecedingOperator(pre);
      pre.removeSucceedingOperator(replaceLit);
      pre.addSucceedingOperator(new OperatorIDTuple(projection, index));
    }

    // Make ReplaceLit the successor of Projection
    projection.removePrecedingOperator(replaceLit);
    projection.setSucceedingOperator(new OperatorIDTuple(replaceLit, 0));

    replaceLit.setPrecedingOperator(projection);

    final HashSet<Variable> hsv = new HashSet<Variable>();
    hsv.addAll(projection.getIntersectionVariables());
    replaceLit.setIntersectionVariables(hsv);
    replaceLit.setUnionVariables(hsv);

    // Connect ReplaceLit to the Projections successors instead of him
    replaceLit.setSucceedingOperators(succs);
View Full Code Here

public class RuleGenerateAddOverProjection extends Rule {

  @Override
  protected void init() {
    final GenerateAddEnv genAdd = new GenerateAddEnv();
    final Projection projection = new Projection();

    genAdd.setSucceedingOperator(new OperatorIDTuple(projection, -1));
    projection.setPrecedingOperator(genAdd);

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

  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final GenerateAddEnv genAdd = (GenerateAddEnv) mso.get("genAdd");
    final Projection projection = (Projection) mso.get("projection");

    final Object[] projVars = projection.getProjectedVariables().toArray();
    final Object[] c = genAdd.getConditions().keySet().toArray();
    for (int i = 0; i < c.length; i++) {
      // Condition should be replaceable after transformation
      if (arrayContains(projVars, (Variable) c[i])) {
        return false;
View Full Code Here

  @Override
  public Tuple<Collection<BasicOperator>, Collection<BasicOperator>> transformOperatorGraph(
      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final GenerateAddEnv genAdd = (GenerateAddEnv) mso.get("genAdd");
    final Projection projection = (Projection) mso.get("projection");

    final Object[] projVars = projection.getProjectedVariables().toArray();
    final Object[] subst = genAdd.getConstants().keySet().toArray();

    for (int i = 0; i < subst.length; i++) {
      if (!arrayContains(projVars, (Variable) subst[i])) {
        genAdd.getConstants().remove(subst[i]);
      }
    }

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

    final int index = genAdd.getOperatorIDTuple(projection).getId();

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

    projection.removePrecedingOperator(genAdd);
    projection.setSucceedingOperator(new OperatorIDTuple(genAdd, 0));

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

    BasicOperator succ;
View Full Code Here

public class RuleDeleteUseLessProjection extends Rule {

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

    subGraphMap = new HashMap<BasicOperator, String>();
    subGraphMap.put(projection, "projection");

    startNode = projection;
View Full Code Here

    startNode = projection;
  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final Projection projection = (Projection) mso.get("projection");
    if (projection.getSucceedingOperators().get(0).getOperator() instanceof Result) {
      return false;
    }
    final LinkedList<BasicOperator> pres = (LinkedList<BasicOperator>) projection
        .getPrecedingOperators();

    final Object[] projVars = projection.getProjectedVariables().toArray();

    final LinkedList<Variable> unionPres = new LinkedList<Variable>();

    BasicOperator pre;
    Object[] union;
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 LinkedList<BasicOperator> pres = (LinkedList<BasicOperator>) projection
        .getPrecedingOperators();
    final LinkedList<OperatorIDTuple> succs = (LinkedList<OperatorIDTuple>) projection
        .getSucceedingOperators();

    BasicOperator pre;
    OperatorIDTuple idTuple;
    // Connect all precessors to all successors
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.