예제 #1
0
 /**
  * This method returns the first found preceding operator, which is connected to this operator
  * with the given id
  *
  * @param id the id of the OperatorIDTuple
  * @return the first found preceding operator, which is connected to this operator with the given
  *     id, otherwise null
  */
 public BasicOperator getPrecedingOperatorWithID(final int id) {
   for (BasicOperator prec : this.getPrecedingOperators()) {
     if (prec.getOperatorIDTuple(this).getId() == id) {
       return prec;
     }
   }
   return null;
 }
  protected void replace(HashMap<Class<?>, HashSet<BasicOperator>> _startNodes) {
    // remove obsolete connections...
    int[] _label_a = null;

    int _label_a_count = 0;
    _label_a = new int[this.o1.length];

    for (lupos.engine.operators.BasicOperator _parent : this.o1) {
      _label_a[_label_a_count] = _parent.getOperatorIDTuple(this.p).getId();
      _label_a_count += 1;

      _parent.removeSucceedingOperator(this.p);
      this.p.removePrecedingOperator(_parent);
    }

    this.p.removeSucceedingOperator(this.o2);
    this.o2.removePrecedingOperator(this.p);

    // add new operators...
    lupos.rif.operator.PredicatePattern[] p_new = null;
    p_new = new lupos.rif.operator.PredicatePattern[this.o1.length];

    for (this._dim_0 = 0; this._dim_0 < p_new.length; this._dim_0 += 1) {
      p_new[this._dim_0] = new lupos.rif.operator.PredicatePattern();
    }

    // add new connections...
    for (this._dim_0 = 0; this._dim_0 < this.o1.length; this._dim_0 += 1) {
      this.o1[this._dim_0].addSucceedingOperator(p_new[this._dim_0]);
      p_new[this._dim_0].addPrecedingOperator(this.o1[this._dim_0]);
    }

    _label_a_count = 0;

    for (lupos.rif.operator.PredicatePattern _parent : p_new) {
      _parent.addSucceedingOperator(new OperatorIDTuple(this.o2, _label_a[_label_a_count]));
      this.o2.addPrecedingOperator(_parent);

      _label_a_count += 1;
    }

    // delete unreachable operators...
    this.deleteOperatorWithoutParentsRecursive(this.p, _startNodes);

    // additional replace method code...
    for (lupos.rif.operator.PredicatePattern tmp_p : p_new) {
      tmp_p.getSucceedingOperators().get(0).setId(id);
      tmp_p.setUnionVariables(
          new java.util.HashSet<lupos.datastructures.items.Variable>(this.p.getUnionVariables()));
      tmp_p.setIntersectionVariables(
          new java.util.HashSet<lupos.datastructures.items.Variable>(
              this.p.getIntersectionVariables()));
      tmp_p.setPredicateName(this.p.getPredicateName());
      tmp_p.setPatternItems(this.p.getPatternItems());
    }
  }