Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
package org.pentaho.di.trans.step;package org.pentaho.di.trans.step;

import java.util.concurrent.TimeUnit;

import org.pentaho.di.core.RowSet;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.core.gui.PrimitiveGCInterface.EImage;
import org.pentaho.di.core.row.RowMetaInterface;

@RowDistributionPlugin(
    code="Overflow",
    name="Overflow",
    description="When an output row set is full, move to the next one"
    )
public class OverflowRowDistributionPlugin implements RowDistributionInterface {

  @Override
  public String getCode() {
    return "Overflow";
  }

  @Override
  public String getDescription() {
    return "When an output row set is full, move to the next one";
  }

  @Override
  public void distributeRow(RowMetaInterface rowMeta, Object[] row, StepInterface step)
      throws KettleStepException {

    RowSet rowSet = step.getOutputRowSets().get(step.getCurrentOutputRowSetNr());

    boolean added = false;
    while (!added) {
      added=rowSet.putRowWait(rowMeta, row, 1, TimeUnit.NANOSECONDS);
      if (added) {
        break;
      }
      step.setCurrentOutputRowSetNr(step.getCurrentOutputRowSetNr()+1);
      if (step.getCurrentOutputRowSetNr()>step.getOutputRowSets().size()-1) {
        step.setCurrentOutputRowSetNr(0);
      }
      rowSet = step.getOutputRowSets().get(step.getCurrentOutputRowSetNr());
    }

  }

  @Override
  public EImage getDistributionImage() {
    return null;
  }

}

Available through right-click on a step: Image Added