issue with tMemorizeRows component

One Star

issue with tMemorizeRows component

Hi,
I have a very simple job which compares previous row with next row. It works fine for one data and does not work for another.
Data type is set to int, it works fine with series : id,1,2,2,2,1,1,2,3,4,5,4,3,2,1
but does not work with actual data : id 1738047321,1738047323, 1738047323, 1738047323, 1738047322,1738047322,1738047323,1738047321,1738047321,1738047323,1738047323,1738047323
I also tried using long as well as string also Smiley Sad, but it won't work.
I am not sure why it is not returning proper results. I am using following code in tjavarow component.
if (id_tMemorizeRows_2 != id_tMemorizeRows_2)
{System.out.println("ID changed");}
else
{System.out.println("ID not changed");}
What i need to do to make this work with the above data.
I am using Talend version 4.2.2.r63143
Thanks
Vaibhav
One Star

Re: issue with tMemorizeRows component

Hi Vaibhav
What error do you get?
Or what wrong result?
Regards,
Pedro
One Star

Re: issue with tMemorizeRows component

Oh sorry,
I missed to explain what is going wrong...
In case of second data set, it is executing the else condition for all cases. There is no error in the job.
Thanks
Vaibhav
One Star

Re: issue with tMemorizeRows component

Hi Vaibhav
I happened to face this issue before that I wrongly modify the data type of this column to String.
Please check the data type again.
Regards,
Pedro
One Star

Re: issue with tMemorizeRows component

There is no issue with the data type.
As i said earlier, same job works fine with first series and it does not work with the second series.
How i verified it ?
1) Take the csv file with the first series of data --> execute it --> gets success
2) Update same csv file with new data set --> execute it --> only second loop gets executed.
Thanks
Vaibhav
Seven Stars

Re: issue with tMemorizeRows component

I think the problem is the example in the help is bad. tMemorizeRows creates an array of objects so you should not use == or != to compare them. Change your expression instead to !id_tMemorizeRows_2.equals(id_tMemorizeRows_2) and see if that works.
One Star

Re: issue with tMemorizeRows component

alevy,
The suggestion which you gave, I tried initially to implement while debugging the issue, But, at that time it didn't work. But, now when i tried, it worked....
if (rep_id_tMemorizeRows_2.equals(rep_id_tMemorizeRows_2))
{
System.out.println("id not changed");
}
else
{
System.out.println("id changed");
}
Above code worked well.
But it is also true that previous code works for one series and does not work for another... This is something Talend dev team people can think of.
Thanks for the quick suggestion.
Vaibhav
Seven Stars

Re: issue with tMemorizeRows component

I think it's a fluke of the comparison in Java and nothing that can be addressed by Talend. I have encountered before cases where == between Integers sometimes is true and sometimes not.