use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class MergeJoinMeta method readRep.
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
try {
int nrKeys1 = rep.countNrStepAttributes(id_step, "keys_1");
int nrKeys2 = rep.countNrStepAttributes(id_step, "keys_2");
allocate(nrKeys1, nrKeys2);
for (int i = 0; i < nrKeys1; i++) {
keyFields1[i] = rep.getStepAttributeString(id_step, i, "keys_1");
}
for (int i = 0; i < nrKeys2; i++) {
keyFields2[i] = rep.getStepAttributeString(id_step, i, "keys_2");
}
List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
infoStreams.get(0).setSubject(rep.getStepAttributeString(id_step, "step1"));
infoStreams.get(1).setSubject(rep.getStepAttributeString(id_step, "step2"));
joinType = rep.getStepAttributeString(id_step, "join_type");
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "MergeJoinMeta.Exception.UnexpectedErrorReadingStepInfo"), e);
}
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class MergeJoinMeta method saveRep.
public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step) throws KettleException {
try {
for (int i = 0; i < keyFields1.length; i++) {
rep.saveStepAttribute(id_transformation, id_step, i, "keys_1", keyFields1[i]);
}
for (int i = 0; i < keyFields2.length; i++) {
rep.saveStepAttribute(id_transformation, id_step, i, "keys_2", keyFields2[i]);
}
List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
rep.saveStepAttribute(id_transformation, id_step, "step1", infoStreams.get(0).getStepname());
rep.saveStepAttribute(id_transformation, id_step, "step2", infoStreams.get(1).getStepname());
rep.saveStepAttribute(id_transformation, id_step, "join_type", getJoinType());
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "MergeJoinMeta.Exception.UnableToSaveStepInfo") + id_step, e);
}
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class MergeRowsMeta method readRep.
@Override
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
try {
int nrKeys = rep.countNrStepAttributes(id_step, "key_field");
int nrValues = rep.countNrStepAttributes(id_step, "value_field");
allocate(nrKeys, nrValues);
for (int i = 0; i < nrKeys; i++) {
keyFields[i] = rep.getStepAttributeString(id_step, i, "key_field");
}
for (int i = 0; i < nrValues; i++) {
valueFields[i] = rep.getStepAttributeString(id_step, i, "value_field");
}
flagField = rep.getStepAttributeString(id_step, "flag_field");
List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
StreamInterface referenceStream = infoStreams.get(0);
StreamInterface compareStream = infoStreams.get(1);
referenceStream.setSubject(rep.getStepAttributeString(id_step, "reference"));
compareStream.setSubject(rep.getStepAttributeString(id_step, "compare"));
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "MergeRowsMeta.Exception.UnexpectedErrorReadingStepInfo"), e);
}
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class MultiMergeJoin method processFirstRow.
private boolean processFirstRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
meta = (MultiMergeJoinMeta) smi;
data = (MultiMergeJoinData) sdi;
TransMeta transMeta = getTransMeta();
TransHopMeta transHopMeta;
StepIOMetaInterface stepIOMeta = meta.getStepIOMeta();
List<StreamInterface> infoStreams = stepIOMeta.getInfoStreams();
StreamInterface stream;
StepMeta toStepMeta = meta.getParentStepMeta();
StepMeta fromStepMeta;
ArrayList<String> inputStepNameList = new ArrayList<String>();
String[] inputStepNames = meta.getInputSteps();
String inputStepName;
for (int i = 0; i < infoStreams.size(); i++) {
inputStepName = inputStepNames[i];
stream = infoStreams.get(i);
fromStepMeta = stream.getStepMeta();
if (fromStepMeta == null) {
// should not arrive here, shoud typically have been caught by init.
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Log.UnableToFindReferenceStream", inputStepName));
}
// check the hop
transHopMeta = transMeta.findTransHop(fromStepMeta, toStepMeta, true);
// there is no hop: this is unexpected.
if (transHopMeta == null) {
// should not arrive here, shoud typically have been caught by init.
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Log.UnableToFindReferenceStream", inputStepName));
} else if (transHopMeta.isEnabled()) {
inputStepNameList.add(inputStepName);
} else {
logDetailed(BaseMessages.getString(PKG, "MultiMergeJoin.Log.IgnoringStep", inputStepName));
}
}
int streamSize = inputStepNameList.size();
if (streamSize == 0) {
return false;
}
String keyField;
String[] keyFields;
data.rowSets = new RowSet[streamSize];
RowSet rowSet;
Object[] row;
data.rows = new Object[streamSize][];
data.metas = new RowMetaInterface[streamSize];
data.rowLengths = new int[streamSize];
MultiMergeJoinData.QueueComparator comparator = new MultiMergeJoinData.QueueComparator(data);
data.queue = new PriorityQueue<MultiMergeJoinData.QueueEntry>(streamSize, comparator);
data.results = new ArrayList<List<Object[]>>(streamSize);
MultiMergeJoinData.QueueEntry queueEntry;
data.queueEntries = new MultiMergeJoinData.QueueEntry[streamSize];
data.drainIndices = new int[streamSize];
data.keyNrs = new int[streamSize][];
data.dummy = new Object[streamSize][];
RowMetaInterface rowMeta;
data.outputRowMeta = new RowMeta();
for (int i = 0, j = 0; i < inputStepNames.length; i++) {
inputStepName = inputStepNames[i];
if (!inputStepNameList.contains(inputStepName)) {
// ignore step with disabled hop.
continue;
}
queueEntry = new MultiMergeJoinData.QueueEntry();
queueEntry.index = j;
data.queueEntries[j] = queueEntry;
data.results.add(new ArrayList<Object[]>());
rowSet = findInputRowSet(inputStepName);
if (rowSet == null) {
throw new KettleException(BaseMessages.getString(PKG, "MultiMergeJoin.Exception.UnableToFindSpecifiedStep", inputStepName));
}
data.rowSets[j] = rowSet;
row = getRowFrom(rowSet);
data.rows[j] = row;
if (row == null) {
rowMeta = getTransMeta().getStepFields(inputStepName);
data.metas[j] = rowMeta;
} else {
queueEntry.row = row;
rowMeta = rowSet.getRowMeta();
keyField = meta.getKeyFields()[i];
String[] keyFieldParts = keyField.split(",");
String keyFieldPart;
data.keyNrs[j] = new int[keyFieldParts.length];
for (int k = 0; k < keyFieldParts.length; k++) {
keyFieldPart = keyFieldParts[k];
data.keyNrs[j][k] = rowMeta.indexOfValue(keyFieldPart);
if (data.keyNrs[j][k] < 0) {
String message = BaseMessages.getString(PKG, "MultiMergeJoin.Exception.UnableToFindFieldInReferenceStream", keyFieldPart, inputStepName);
logError(message);
throw new KettleStepException(message);
}
}
data.metas[j] = rowMeta;
data.queue.add(data.queueEntries[j]);
}
data.outputRowMeta.mergeRowMeta(rowMeta.clone());
data.rowLengths[j] = rowMeta.size();
data.dummy[j] = RowDataUtil.allocateRowData(rowMeta.size());
j++;
}
return true;
}
use of org.pentaho.di.trans.step.errorhandling.StreamInterface in project pentaho-kettle by pentaho.
the class FuzzyMatchMeta method readRep.
public void readRep(Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases) throws KettleException {
try {
String lookupFromStepname = rep.getStepAttributeString(id_step, "lookup_from_step");
StreamInterface infoStream = getStepIOMeta().getInfoStreams().get(0);
infoStream.setSubject(lookupFromStepname);
lookupfield = rep.getStepAttributeString(id_step, "lookupfield");
mainstreamfield = rep.getStepAttributeString(id_step, "mainstreamfield");
outputmatchfield = rep.getStepAttributeString(id_step, "outputmatchfield");
outputvaluefield = rep.getStepAttributeString(id_step, "outputvaluefield");
caseSensitive = rep.getStepAttributeBoolean(id_step, "caseSensitive");
closervalue = rep.getStepAttributeBoolean(id_step, "closervalue");
minimalValue = rep.getStepAttributeString(id_step, "minimalValue");
maximalValue = rep.getStepAttributeString(id_step, "maximalValue");
separator = rep.getStepAttributeString(id_step, "separator");
algorithm = getAlgorithmTypeByCode(Const.NVL(rep.getStepAttributeString(id_step, "algorithm"), ""));
int nrvalues = rep.countNrStepAttributes(id_step, "return_value_name");
allocate(nrvalues);
for (int i = 0; i < nrvalues; i++) {
value[i] = rep.getStepAttributeString(id_step, i, "return_value_name");
valueName[i] = rep.getStepAttributeString(id_step, i, "return_value_rename");
}
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "FuzzyMatchMeta.Exception.UnexpecteErrorReadingStepInfoFromRepository"), e);
}
}
Aggregations