Package lupos.engine.operators.multiinput.optional

Examples of lupos.engine.operators.multiinput.optional.Optional


public class RuleGenerateAddOverOptional extends Rule {

  @Override
  protected void init() {
    final GenerateAddEnv genAdd = new GenerateAddEnv();
    final Optional optional = new Optional();

    // Only left Operand
    genAdd.setSucceedingOperator(new OperatorIDTuple(optional, 0));
    optional.setPrecedingOperator(genAdd);

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


    startNode = genAdd;
  }

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

    final Object[] optionalVars = optional.getIntersectionVariables()
        .toArray();
    final Object[] v = genAdd.getConstants().keySet().toArray();

    // All Tuples should not have a join-partner of the Optional on the left
    // side
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 Optional optional = (Optional) mso.get("optional");

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

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

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

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

    BasicOperator succ;
View Full Code Here

public class RuleOptionalWithParallelOperands extends
    RuleJoinWithParallelOperands {
  @Override
  protected void init() {
    final Operator a = new Optional();

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

    startNode = a;
View Full Code Here

public class RuleOptionalLastParallelOperands extends
    RuleJoinLastParallelOperands {

  @Override
  protected void init() {
    final Operator a = new Optional();

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

    startNode = a;
View Full Code Here

        }
      }
      for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        final Node n = node.jjtGetChild(i);
        if (n instanceof ASTOptionalConstraint) {
          final Optional opt = new Optional();
          connection.connectAndSetAsNewOperatorConnection(opt, 1);
          n.accept(this, connection, graphConstraint);
          connection.setOperatorConnection(opt, 0);
        } else if (n instanceof ASTMinus) {
          Minus minus = null;
View Full Code Here

public class RuleReplaceLitOverOptional extends Rule {

  @Override
  protected void init() {
    final ReplaceLit replaceLit = new ReplaceLit();
    final Optional optional = new Optional();

    // Only left Operand
    replaceLit.setSucceedingOperator(new OperatorIDTuple(optional, 0));
    optional.setPrecedingOperator(replaceLit);

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

    startNode = replaceLit;
  }

  @Override
  protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
    final Optional optional = (Optional) mso.get("optional");
    final ReplaceLit replaceLit = (ReplaceLit) mso.get("replaceLit");

    final Object[] optionalVars = optional.getIntersectionVariables()
        .toArray();
    final LinkedList<Variable> v = replaceLit.getSubstitutionsLiteralLeft();

    // If there is minimum one substitution which can be pulled down
    for (int i = 0; i < v.size(); i++) {
View Full Code Here

      final Map<String, BasicOperator> mso,
      final BasicOperator rootOperator) {
    final Collection<BasicOperator> deleted = new LinkedList<BasicOperator>();
    final Collection<BasicOperator> added = new LinkedList<BasicOperator>();
    final ReplaceLit replaceLit = (ReplaceLit) mso.get("replaceLit");
    final Optional optional = (Optional) mso.get("optional");

    final ReplaceLit replaceLitUnder = new ReplaceLit();
    added.add(replaceLitUnder);

    final Object[] optionalVars = optional.getIntersectionVariables()
        .toArray();
    final LinkedList<Variable> replaceLitLeft = replaceLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> replaceLitRight = replaceLit
        .getSubstitutionsLiteralRight();
    Variable var;
    Literal lit;

    for (int i = 0; i < replaceLitLeft.size(); i++) {
      var = replaceLitLeft.get(i);
      // Split ReplaceLit and pull only not intersection variables
      // downwards
      if (!arrayContains(optionalVars, var)) {
        lit = replaceLitRight.get(i);
        replaceLitUnder.addSubstitution(var, lit);
        replaceLit.removeSubstitutionVars(i);
      }
    }

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

    // If everything could be pushed downwards, the old ReplaceLit can be
    // deleted
    if (replaceLit.getSubstitutionsLiteralLeft().size() == 0) {
      BasicOperator pre;
      for (int i = 0; i < pres.size(); i++) {
        pre = pres.get(i);
        pre.addSucceedingOperator(new OperatorIDTuple(optional, index));
        pre.removeSucceedingOperator(replaceLit);
        optional.addPrecedingOperator(pre);
      }
      optional.removePrecedingOperator(replaceLit);
      deleted.add(replaceLit);
    }

    // Insert the new ReplaceLit under the Optional
    optional.setSucceedingOperator(new OperatorIDTuple(replaceLitUnder, 0));

    replaceLitUnder.setPrecedingOperator(optional);
    replaceLitUnder.setSucceedingOperators(succs);

    BasicOperator succ;
View Full Code Here

TOP

Related Classes of lupos.engine.operators.multiinput.optional.Optional

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.