我想问一下如果在使用tMap组件时在Talend Data Integration中运行一个作业,如何在每一行创建一个特定的计数器
例如,这是每行中有5个数据具有0个计数器的结果
表动物 动物柜台 斑马0 斑马0 斑马0 斑马0 斑马0
当我使用tMap运行一个作业时,我想要这样的最终结果
表动物:最终结果 动物柜台 斑马0 斑马0 斑马0 斑马0 斑马0 斑马1 斑马1 斑马1 斑马1 斑马1
每次运行作业时,计数器上的字段总是递增一,数据总是插入
问候
我看到的两个选项是:
我想告诉你另一种做你想要的东西。
而不是使用tMap,我使用的是tJavaRow组件,结果将与您要求的相同,但是使用java代码实现。
这份工作从.csv读取通过tFileInputDelimited,它已经获得了下一个qazxsw poi。
下面你将看到一个tJavaRow组件,其中inside是java代码,最后是tlogRow组件来显示最终数据集。 - data -
代码里面的tJavaRow
Job Image
在这里你有output_row.Animal = input_row.Animal; /*Code generated according to input schema and output schema*/
if (context.counter == -1){ /*Conditional to hold just the first row interaction*/
context.counter=0; /*Initialization of the context variable (Counter)*/
output_row.Counter = context.counter;
context.previousRecord = row1.Animal; /*Store the previous animal name*/
}else{ /*the java thread execution takes this way after the first interaction*/
if(row1.Animal.equals(context.previousRecord)){ /*compare the actual animal (row1.Animal) vs the previous one*/
output_row.Counter = context.counter;
context.previousRecord = row1.Animal;
}else{
context.counter++;
output_row.Counter = context.counter;
context.previousRecord = row1.Animal;
}
}
!
\(ToT)/