import java.text.DecimalFormat;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
if (first) {
first = false;
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
String GMSFHM = get(Fields.In, "GMSFHM").getString(r);
String XM = get(Fields.In, "XM").getString(r);
String YXX = get(Fields.In, "YXX").getString(r);
String rawId = GMSFHM+"_"+XM+"_"+YXX;
int hashCode = rawId.hashCode();
int regionCode = Math.abs(hashCode) % 3;
//格式化分区号
DecimalFormat df = new DecimalFormat("00");
String ID = df.format(regionCode)+"_"+rawId;
get(Fields.Out, "ID").setValue(r, ID);
putRow(data.outputRowMeta, r);
return true;
}
设置参数
使用参数
int regions = Integer.valueOf(getParameter("regions"));