Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Adding each row of a table to collection(HashMap)

Hi,

 

I wanted to parallel execute the same child job with the values read from a table.

How can I do this?

 

Using tSetGlobalVar I have set 2 global HashMap varaibles - say sharedMap1 and sharedMap2 in tPrejob step.

In sub-task, I am reading the table - fromId, toID and many other fields. 

I wanted to save each row values to the collection - 1st record to sharedMap1, 2nd record to sharedMap2.

How can I achieve this?

 

Then using tParallelize I can call both the tRunJob with the HashMap variables.

 

Thanks. 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

Its working now.

tDBInput ---->(row1 Main) tJavaFlex

| (OnSubjobOk)

tJava_2

 

tJavaFlex:

start code:

java.util.List<java.util.Map<String, String>> sharedList=new java.util.ArrayList<java.util.Map<String, String>>();

Main code:

sharedList.add(new java.util.HashMap(){{
put("ID",row1.ID);

}}
);

End code:

 globalMap.put("sharedList",sharedList); 

 

tJava_2:

System.out.println(((java.util.ArrayList)globalMap.get("sharedList")).size());

System.out.println(((java.util.HashMap)((java.util.ArrayList)globalMap.get("sharedList")).get(0)).get("ID"));

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Hi,

 

    Could you please provide the sample job flow screenshots with some sample input datasets you are trying to process and output datasets you are trying to achieve?

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Hi,

 

Please find in the attachment.

For testing I have created a sqlite table called TEST with single column - ID as int.

 

Thanks


job_test_tParallel.zip
Anonymous
Not applicable
Author

Hi,

 

Its working now.

tDBInput ---->(row1 Main) tJavaFlex

| (OnSubjobOk)

tJava_2

 

tJavaFlex:

start code:

java.util.List<java.util.Map<String, String>> sharedList=new java.util.ArrayList<java.util.Map<String, String>>();

Main code:

sharedList.add(new java.util.HashMap(){{
put("ID",row1.ID);

}}
);

End code:

 globalMap.put("sharedList",sharedList); 

 

tJava_2:

System.out.println(((java.util.ArrayList)globalMap.get("sharedList")).size());

System.out.println(((java.util.HashMap)((java.util.ArrayList)globalMap.get("sharedList")).get(0)).get("ID"));