Beispiel #1
0
  /**
   * Removes the <code>TupleSink</code>
   *
   * @param tupleSink The <code>TupleSink</code> to remove
   */
  public void removeTupleSink(final LeftTupleSink tupleSink) {
    if (this.sink instanceof EmptyLeftTupleSinkAdapter) {
      throw new IllegalArgumentException("Cannot remove a sink, when the list of sinks is null");
    }

    if (this.sink instanceof SingleLeftTupleSinkAdapter) {
      this.sink = EmptyLeftTupleSinkAdapter.getInstance();
    } else {
      final CompositeLeftTupleSinkAdapter sinkAdapter = (CompositeLeftTupleSinkAdapter) this.sink;
      sinkAdapter.removeTupleSink(tupleSink);
      if (sinkAdapter.size() == 1) {
        this.sink =
            new SingleLeftTupleSinkAdapter(this.getPartitionId(), sinkAdapter.getSinks()[0]);
      }
    }
  }
Beispiel #2
0
  protected LeftTupleSinkPropagator addTupleSink(
      final LeftTupleSinkPropagator sinkPropagator,
      final LeftTupleSink tupleSink,
      final BuildContext context) {
    if (sinkPropagator instanceof EmptyLeftTupleSinkAdapter) {
      // otherwise, we use the lighter synchronous propagator
      return new SingleLeftTupleSinkAdapter(this.getPartitionId(), tupleSink);
    }

    if (sinkPropagator instanceof SingleLeftTupleSinkAdapter) {
      CompositeLeftTupleSinkAdapter sinkAdapter =
          new CompositeLeftTupleSinkAdapter(this.getPartitionId());
      sinkAdapter.addTupleSink(sinkPropagator.getSinks()[0]);
      sinkAdapter.addTupleSink(tupleSink);
      return sinkAdapter;
    }

    ((CompositeLeftTupleSinkAdapter) sinkPropagator).addTupleSink(tupleSink);
    return sinkPropagator;
  }