Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello ,
I Have a problem as described below:
I use TOS7.1 with windows os 2008 and import old tos version:4.1.2 project,it's display a warning in the file:Utils,path:code->Routines->system
The warning in "IPersistableRow",but i didn't have IPersistableRow.item 、IPersistableRow.properties in this path ,i only have file:IPersistableRow.java .
How to fix it ,thanks a lot.
Utils's code with below:
package routines;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;
import org.talend.designer.components.hashfile.memory.AdvancedMemoryHashFile;
import routines.system.IPersistableRow;
public class Utils {
public static int size(
AdvancedMemoryHashFile<? extends IPersistableRow> hashFile) {
int result = 0;
if (hashFile != null) {
Iterator<? extends IPersistableRow> iterator = hashFile.iterator();
while (iterator.hasNext()) {
iterator.next();
result += 1;
}
}
return result;
...
If IPersistableRow was not available to your job, the job would not compile. So you do not have to worry about that.
I have figured out why this is not working. The backend code for dealing with tHash components has changed (the code inside the job). The way in which you are getting a reference to the hash needs to change. This is how I did it in my test job, so that I could use your code....
//Get a reference to the MapHashFile org.talend.designer.components.hashfile.common.MapHashFile tempHash = org.talend.designer.components.hashfile.common.MapHashFile.getMapHashFile(); //Get a reference to the AdvancedMemoryHashFile org.talend.designer.components.hashfile.memory.AdvancedMemoryHashFile<row1Struct> hashFile = ((org.talend.designer.components.hashfile.memory.AdvancedMemoryHashFile<row1Struct>)tempHash.getResourceMap().get("tHashFile_CommunityTestJob_"+ pid + "_tHashOutput_1")); //Print out the result of your method System.out.println(routines.TestRoutines.size(hashFile));
The above works. Pay attention to "row1Struct". This is my row1 class.
Having shown you how to get round this, I should point out some built-in functionality to solve your problems here. You can get the size of the tHash using this code....
((Integer)globalMap.get("tHashOutput_1_NB_LINE"))
....this is for a tHashOutput called tHashOutput_1. It is exactly same format {Name}_NB_LINE for all components which output and input rows actually.
Regarding your isnull function, you can test the variable above.
Can you show a screenshot (or even better, the text) of the error please? Also, could you show us what your routine's code looks like in the code window? You appear to be jumping a few versions, so there may be a requirement to refactor this a little.
Hello,
I only have IPersistableRow.java on the path(E:\talend_etl\applications\TOS_DI-20181026_1147-V7.1.1\workspace\FSP_CRM\poms\code\routines\src\main\java\routines\system\IPersistableRow.java).
My job running need function:size ,but it'not work ,and all of the function in Utils has same problem.
Please give me some suggestions,thanks.
screenshot :
These are just warnings. It looks like a generics warning (https://en.wikipedia.org/wiki/Generics_in_Java). Is the routine not working or causing errors?
Dear Sir:
It's error when I run job.
I found tJDBCOutput_3 Call Utils function:size cause this error,and the Utils all of function doesn't work.
So I think the "IPersistableRow" can't use in Utils.
please help,thanks.
error message :
Exception in component tJDBCOutput_3 (OnDemand_PhaseIn_Oppty_NewProject_Main_1)
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at org.talend.components.jdbc.runtime.setting.JDBCSQLBuilder.createColumnList(JDBCSQLBuilder.java:185)
at org.talend.components.jdbc.runtime.writer.JDBCOutputWriter.open(JDBCOutputWriter.java:146)
at org.talend.components.jdbc.runtime.writer.JDBCOutputUpdateWriter.open(JDBCOutputUpdateWriter.java:43)
...
This is the error.....
"java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String"
....it is saying you are trying to cast an Integer to a String.
Now this *may* be related to IPersistableRow, but so far I have not seen a link to this. Can you tell me why you believe it to be this?
Dear Sir:
The Job's next step like this,also used utils's function:isNotEmpty and it's no error,but it's doesn't work.
SO I think it's cause the "IPersistableRow".
Thanks~
code:
public static boolean isNotEmpty(
AdvancedMemoryHashFile<? extends IPersistableRow> hashFile) {
if (hashFile == null) {
return false;
}
boolean result = false;
Iterator<? extends IPersistableRow> iterator = hashFile.iterator();
while (iterator.hasNext()) {
result = true;
break;
}
return result;
}
If IPersistableRow was not available to your job, the job would not compile. So you do not have to worry about that.
I have figured out why this is not working. The backend code for dealing with tHash components has changed (the code inside the job). The way in which you are getting a reference to the hash needs to change. This is how I did it in my test job, so that I could use your code....
//Get a reference to the MapHashFile org.talend.designer.components.hashfile.common.MapHashFile tempHash = org.talend.designer.components.hashfile.common.MapHashFile.getMapHashFile(); //Get a reference to the AdvancedMemoryHashFile org.talend.designer.components.hashfile.memory.AdvancedMemoryHashFile<row1Struct> hashFile = ((org.talend.designer.components.hashfile.memory.AdvancedMemoryHashFile<row1Struct>)tempHash.getResourceMap().get("tHashFile_CommunityTestJob_"+ pid + "_tHashOutput_1")); //Print out the result of your method System.out.println(routines.TestRoutines.size(hashFile));
The above works. Pay attention to "row1Struct". This is my row1 class.
Having shown you how to get round this, I should point out some built-in functionality to solve your problems here. You can get the size of the tHash using this code....
((Integer)globalMap.get("tHashOutput_1_NB_LINE"))
....this is for a tHashOutput called tHashOutput_1. It is exactly same format {Name}_NB_LINE for all components which output and input rows actually.
Regarding your isnull function, you can test the variable above.
Thank you for your patience and advice,it's very useful to me.
I'll study the others function of the Utils.java.
No problem. Sometimes debugging code remotely can be a challenge 🙂