Ejemplo n.º 1
0
 /**
  * This is a helper method of the method Object visit(SimpleOperatorGraphVisitor visitor)
  *
  * @param visitor The visitor to be applied to each node
  * @param hs the already visited operators
  * @return The object retrieved from processing the visitor on this operator.
  */
 private Object visit(final SimpleOperatorGraphVisitor visitor, final HashSet<BasicOperator> hs) {
   if (hs.contains(this)) return null;
   hs.add(this);
   final Object result = visitor.visit(this);
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     opid.getOperator().visit(visitor, hs);
   }
   return result;
 }
Ejemplo n.º 2
0
 public void removeFromOperatorGraphWithoutConnectingPrecedingWithSucceedingOperators() {
   for (final OperatorIDTuple oidtuple : this.getSucceedingOperators()) {
     oidtuple.getOperator().removePrecedingOperator(this);
   }
   this.succeedingOperators.clear();
   for (final BasicOperator prec : this.getPrecedingOperators()) {
     prec.removeSucceedingOperator(this);
   }
   this.precedingOperators.clear();
 }
Ejemplo n.º 3
0
 public void removeFromOperatorGraph() {
   for (final OperatorIDTuple oidtuple : this.getSucceedingOperators()) {
     oidtuple.getOperator().removePrecedingOperator(this);
     oidtuple.getOperator().addPrecedingOperators(this.getPrecedingOperators());
   }
   for (final BasicOperator prec : this.getPrecedingOperators()) {
     prec.removeSucceedingOperator(this);
     prec.addSucceedingOperators(this.getSucceedingOperators());
   }
 }
Ejemplo n.º 4
0
 /**
  * This is a helper method of the method Object visit(SimpleOperatorGraphVisitor visitor)
  *
  * @param visitor The visitor to be applied to each node
  * @param hs the already visited operators
  * @return The object retrieved from processing the visitor on this operator.
  */
 private <T> Object visit(
     final OperatorGraphVisitor<T> visitor, final T data, final HashSet<BasicOperator> hs) {
   if (hs.contains(this)) return null;
   hs.add(this);
   final T result = visitor.visit(this, data);
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     opid.getOperator().visit(visitor, result, hs);
   }
   return result;
 }
Ejemplo n.º 5
0
 protected Message forwardMessageDebug(final Message msg, final DebugStep debugstep) {
   msg.setVisited(this);
   Message result = msg;
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     if (!msg.hasVisited(opid.getOperator())) {
       final Message msg2 = msg.clone();
       result = opid.getOperator().receiveDebug(msg2, this, debugstep);
     }
   }
   return result;
 }
Ejemplo n.º 6
0
  public void dump(final String prefix, final HashSet<BasicOperator> visited) {
    if (visited.contains(this)) {
      return;
    }

    visited.add(this);

    System.out.println(prefix + this.toString());

    for (final OperatorIDTuple childIDT : this.succeedingOperators) {
      final BasicOperator child = childIDT.getOperator();

      child.dump(prefix + "-", visited);
    }
  }
Ejemplo n.º 7
0
 /**
  * This method removes the succeeding operator
  *
  * @param succeedingOperator the succeeding operator to be removed
  */
 public void removeSucceedingOperator(final BasicOperator succeedingOperator) {
   if (succeedingOperator != null) {
     boolean change = true;
     while (change) {
       change = false;
       for (final OperatorIDTuple oit : this.succeedingOperators) {
         if (oit.getOperator().equals(succeedingOperator)) {
           this.succeedingOperators.remove(oit);
           change = true;
           break;
         }
       }
     }
   }
 }
Ejemplo n.º 8
0
 /**
  * This method is a helper method of detectCycles.
  *
  * @seealso detectCycles
  */
 private void detectCycles(final List<BasicOperator> hs, final Set<BasicOperator> visited) {
   // System.out.println(this);
   if (visited.contains(this)) {
     return;
   }
   hs.add(this);
   visited.add(this);
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     final int i = hs.indexOf(opid.getOperator());
     if (i >= 0) {
       opid.getOperator().cycleOperands.add(this);
       // cycleOperands.add(opid.getOperator());
       for (int j = i + 1; j < hs.size(); j++) {
         hs.get(j).cycleOperands.add(hs.get(j - 1));
       }
     }
   }
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     opid.getOperator().detectCycles(hs, visited);
   }
   hs.remove(this);
 }
Ejemplo n.º 9
0
  /**
   * This is a helper method of the method Object visit(SimpleOperatorGraphVisitor visitor)
   *
   * @param visitor The visitor to be applied to each node
   * @param hs the already visited operators
   * @return The object retrieved from processing the visitor on this operator.
   */
  private Object visitAndStop(
      final SimpleOperatorGraphVisitor visitor, final HashSet<BasicOperator> hs) {
    if (hs.contains(this)) {
      return null;
    }

    hs.add(this);

    Object result = visitor.visit(this);

    if (result != null) {
      return result;
    }

    for (final OperatorIDTuple opid : this.succeedingOperators) {
      result = opid.getOperator().visitAndStop(visitor, hs);

      if (result != null) {
        return result;
      }
    }

    return result;
  }
Ejemplo n.º 10
0
 /**
  * Replaces this operator with a replacement operator
  *
  * @param replacement The replacement operator
  */
 public void replaceWith(final BasicOperator replacement) {
   for (final BasicOperator preOp : this.precedingOperators) {
     for (final OperatorIDTuple opid : preOp.succeedingOperators) {
       if (opid.getOperator().equals(this)) {
         opid.setOperator(replacement);
       }
     }
   }
   for (final OperatorIDTuple sucOp : this.succeedingOperators) {
     for (int i = 0; i < sucOp.getOperator().precedingOperators.size(); i++) {
       if (sucOp.getOperator().precedingOperators.get(i).equals(this)) {
         sucOp.getOperator().precedingOperators.set(i, replacement);
       }
     }
   }
 }
Ejemplo n.º 11
0
 /**
  * This method returns the first OperatorIDTuple in the list of succeeding operators, which
  * contains the given operator
  *
  * @param op the operator to besearched for in the list of succeeding operators.
  * @return the first OperatorIDTuple, which contains op
  */
 public OperatorIDTuple getOperatorIDTuple(final BasicOperator op) {
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     if (opid.getOperator().equals(op)) return opid;
   }
   return null;
 }