在我的插件中,我尝试从上一步获取元数据信息,以便我可以根据元数据信息(列名)对行数据进行一些处理。
它可以根据数据正常工作,因为 r = getRow() 可以获取数据。但是当调用 getInputRowMeta() 来获取上一步的行元时,它会抛出非指针异常。
代码示例如下(主要是 processRow() 函数。)
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
meta = (NAAClientStepMeta) smi;
data = (NAAClientStepData) sdi;
option = meta.getOption();
message = option;
if (first) {
first = false;
if(option.equals("Publisher AccountIDs")){
getInputRowMeta().size(); // don't work here, throw exception.
RowMetaInterface rm = (RowMetaInterface) getInputRowMeta().clone();
data.outputRowMeta = rm;
meta.getFields(rm, getStepname(), null, null, this);
//String previousSteps[] = transMeta.getPrevStepNames("New Acquisio API Client");
//RowSet rowSet = this.findOutputRowSet(transMe);
//RowMetaInterface rowMeta = rowSet.getRowMeta();
r = getRow();
调用getInputRowMeta()时,抛出异常如下:
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0 stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Unexpected error
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : java.lang.NullPointerException
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at com.acquisio.kettle.plugins.NAAClientStep.processRow(NAAClientStep.java:183)
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at org.pentaho.di.trans.step.RunThread.run(RunThread.java:50)
2015/08/05 14:11:00 - New Acquisio API Client 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : at java.lang.Thread.run(Thread.java:745)
有没有我应该设置的 StepMeta 类、StepData 类的地方?