One Star

[resolved] Row Count for tMap Output

I must be missing something obvious. I need to make a processing decision based on whether or not I have rows in an output from a tMap, like exiting the job if there aren't any. I was looking for something like NB_LINE used by the file shapes but it would appear that information isn't available for tMap outputs.
Can anyone point me in the right direction for determining the rowcount from tMap output?
Thanks!
5 REPLIES
Moderator

Re: [resolved] Row Count for tMap Output

Hi,
If I understand you well, do you want to count the total number of records have been proceed? If so please refer to this forum:Forum 28198, I think it will be helpful for you.
If not, could you give us more info about your requirement? Elaborating your case with an example with input and expected output values will be appreciated.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Row Count for tMap Output

Hi Sabrina,
I'm looking for the row count for just one of the outputs from the tMap.
So far, I haven't hit a requirement to know the total records the tMap produced.
Thank you
- Bryan
Community Manager

Re: [resolved] Row Count for tMap Output

Hi Bryan
You can define counter on tJavaFlex after tMap, and use a runIf connector to fires next processing base on a condition. see my screenshot
start code on tJavaFlex:
int nb=0;

main code on tJavaFlex:
nb++;

end code on tJavaFlex:
globalMap.put("nb_line",nb);//put the total nb of lines to a global vriable for use later when needed.
if(nb==0){
globalMap.put("hasData",false);
}else {
globalMap.put("hasData",true);
}

set the condition of runIf as below if you want to fire another process if the output has rows.
(Boolean)globalMap.get("hasData")
set the condition of runIf as below if you don't want to fire another process if the output has no rows.
!(Boolean)globalMap.get("hasData")
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Row Count for tMap Output

Thanks Shong! That looks like what I need.
Added that behavior into my solution & the job ends as it should.
Bryan
Community Manager

Re: [resolved] Row Count for tMap Output

Thanks Shong! That looks like what I need.
Added that behavior into my solution & the job ends as it should.
Bryan

Good news, thanks for your feedback!Smiley Wink
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business