How to pass tHashArray between child jobs?

Five Stars

How to pass tHashArray between child jobs?

I use the tHashOutput component to hold lookup data selected from our database.


How can I pass the tHashOutput to additional child-jobs that use the same lookup data?

Right now each child-job is re-querying the database for the same lookup data.



Thank you




Sixteen Stars

Re: How to pass tHashArray between child jobs?

I'm afraid you can't do this, but with a bit of Java you can do something very similar. Here are the high level steps, but you will need to be proficient in Java.


1) Create a routine (a Java class) to hold your data structure. Simple getters and setters.

2) Use a tJavaFlex and create an ArrayList<YourClass> in the Start Code

3) In the Main Code section read in your data to an instance of your class and add it to your ArrayList created in the Start Code section

4) In the End Code section, add your ArrayList to the globalMap


At this point you have your data in memory.


5) In your child job create a context variable of class Object.

6) In your tRunJob pass the globalMap data to the new Object context variable.

7) In your child job use a tJavaFlex and in the Start Code section cast your context variable's type to be ArrayList<YourClass>

8) Create an Iterator in the Start Code and initiate a While loop using the Iterator

9) In the Main Code section retrieve each instance of YourClass objects and retrieve the data using your getters. Pass this data to Talend columns.

10) In the End Code section close the While loop


If you are proficient in Java this should be reasonably straight forward. You may need to look at the tJavaFlex documentation to see how it works. 


I use this technique a lot when I want to pass data sets to child jobs.