When working with RDBMS or Web Services components, Talend Open Studio jobs use Flows. For systems programming -- file operations, etc. -- jobs use Iterators. Use a Flow where possible, but keep things as Iterate if most of the components are Iterate connection-based.
In Talend Open Studio, looping or repeating actions are formed using either Flows or Iterators. To bridge the two, there are adapter components: tIterateToFlow, tFlowToIterate.
Take the following job as an example
Iterate
Two tFileLists are used to drive the processing (a System.out.println). The first tFileList uses the Iterate connector fed into a tJava. For each file found in the tFileList, the tJava is invoked. No data is sent to the tJava. The tJava accesses a global variable available after each tFileList iteration.
Flow
To convert the list of files into a Flow where each file is a row, use the tIterateToFlow adapter. This requires defining a schema that will be filled in the Mapping section of the tIterateToFlow adapter.
Because the tFileList is converted to a Flow, accessing global variables isn't needed. The data is available using the standard 'row' syntax like this. This means that Flow-based components like tFilterRow can be used most effectively (recording the number of rows processed, etc.).
Depending on your Job, you have flexibility in selecting an Iterate or Flow. There are adapters that convert from one to the other. One rule of thumb in making your selection is if your job would benefit from having a structured schema associated with you iteration-based components. In this post, a single-field schema is used to transport the values from the tFileList. This could be expanded to additional values.
In Talend Open Studio, looping or repeating actions are formed using either Flows or Iterators. To bridge the two, there are adapter components: tIterateToFlow, tFlowToIterate.
Take the following job as an example
Two Forms of Repeating Actions in TOS |
Two tFileLists are used to drive the processing (a System.out.println). The first tFileList uses the Iterate connector fed into a tJava. For each file found in the tFileList, the tJava is invoked. No data is sent to the tJava. The tJava accesses a global variable available after each tFileList iteration.
tJava Code Iterate Connector |
To convert the list of files into a Flow where each file is a row, use the tIterateToFlow adapter. This requires defining a schema that will be filled in the Mapping section of the tIterateToFlow adapter.
Single Column Schema of a tIterateToFlow |
Flow-based Code Displaying tFileList |
Thanks for providing such a nice collection of Talend tutorials. helps me a lot. Learn more Talend open studio.
ReplyDeleteTalend Open Studio Data Integration Online training
Talend Big Data Integration Online training