PDI Step Plugin Development

PDI Step Plugin Development

TODO: Add, Clean, Fix (This is better than nothing)

Intro

Check out the DummyPlugin example:

http://wiki.pentaho.com/display/EAI/DummyPlugin+3+plugin+page

The code is pretty helpful.

Basically, every Transformation Step has 4 classes:

- Plugin: Main processing component

- Meta: Configuration information (How the step was configured in spoon)

- Data: Runtime data (Each running instance of the thread can keep track of state here)

- Dialog: Configuration dialog (Used in Spoon)

How to read in rows:

The Plugin is the "core" of the step and contains the all important processRow(StepMetaInterface smi, StepDataInterface sdi) method.

This method is executed continuously and the getRow() method is invoked to pull data from the input stream for processing. getInputRowMeta() can be used to fetch information about the structure of the Object array returned by getRow(); (size, type, etc...)

NOTE: Do not go by the size of the Object[] returned by getRow(), it is allocated in chunks. Get the field count for the incoming row from getInputRowMeta().

How to create new fields for output:

In the processRow(...) method you invoke putRow(meta, row) to send a row to the output stream (onto the next step). You determine what the meta is, a simple way to accomplish field addition is to copy the input row meta and add your output field meta to it. Then use that as the outputMeta.

Checkout

http://source.pentaho.org/svnkettleroot/Kettle/trunk/src/org/pentaho/di/trans/steps/rowgenerator/RowGenerator.java for an example.

NOTE: RowGenerateMeta.getFields(...) is used to tell the UI what the outputMeta will be at build time. This is important to do.

Loading and Saving

of a step are accomplished in the StepMeta with the following four methods:

Repository:

- readRep(...)

- saveRep(...)

File:

- loadXml(...)

- getXml(...)

Other confusing links:

http://wiki.pentaho.com/display/COM/PDI+Plugin+Loading

http://wiki.pentaho.com/display/EAI/Writing+your+own+Pentaho+Data+Integration+Plug-In