Author : Girish Mallula
Introduction
It is great challenge for Java developer who wanted to implement some the concepts like “Recursive Looping” which exist in Java.
Recursive looping is one of the topic which is hard to replicate in Talend but it is not impossible.
Recursive Loop
The process in which a function calls itself directly or indirectly is called recursion and the corresponding method is called as recursive method. For example lets take “Factorial of a Number Using Recursion Loop”
class Fact {
static int fact( int n ) {
if (n != 0) // Loop breaking condition
return n * fact(n-1); // recursive loop
else
return 1;
}
public static void main(String[] args) {
int num = 5;
int value = fact(num);
System.out.println(num + " factorial = " + value);
}
}
Let’s start in Talend Studio
- Let me start with a practical user case to demonstrate recursive looping in Talend. So, let’s take a simple usescase where we need retrieve all the files which exists in root folder and its sub directories without using tFileList sub directories option.
2. So here is folder structure there is root directory and under there are multiple folders and files.
3. Initially I am storing my root directory location in a temp file. And this temp file acts as “Parameter Value” for my functionality.
4. And I am using tLoop component to iterate though my functionality.
5. Here I am using “isLoopBreaker” context variable to break my loop. This variable is sent be true when there is no sub folder found in the root directory.
6. List of main compounds and their purposes:
- tLoop -> to the loop thought the flow of compounds
- tFileInputDelimeter -> to retrieve folder details which are stored in temp file
- tFlowToIterate -> to loop thought all the sub folders
- tFileList -> to get properties of all files and folders
- tMap -> it is used to split flow of folders and files details
- tFileOutputDelimeter -> to store folder details in the temp file
- tHashMap -> to store in the details of files in hash map
7. And you will get list of files from tHashOutput.
8. In the result, tLogRow_3 will print list of folder at each level. And tLogRow_2 will print list of files.
9. Happy Learning !!
Heya i am for the first time here. I came across this board and I
find It really helpful & it helped me out much. I hope
to provide something again and help others such as you aided me.
LikeLike
Thank you so much.
LikeLike
If some one wants expert view on the topic
of running a blog after that i recommend him/her to pay a quick visit this web
site, Keep up the nice work.
LikeLike
Fantastic blog! Do you have any recommendations for aspiring writers?
I’m hoping to start my own site soon but I’m
a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there
that I’m totally confused .. Any tips? Thanks a lot!
LikeLike
Thanks for the feedback. Recommendations -> if you keep writing over a period of time you will be a great author. Just make sure you provide right content. No Ad’s please. make it simple. I started with WordPress – easy to maintain and quick to write blogs.
LikeLike
I don’t know if it’s just me or if everybody else encountering problems with your site.
It seems like some of the written text in your posts are running off the screen. Can someone else please
provide feedback and let me know if this is happening to them too?
This might be a issue with my internet browser because I’ve
had this happen previously. Cheers
LikeLike
Can you post me the screen shots. I can look into it.
LikeLike
Thankyou for this rattling post, I am glad I discovered this internet site on yahoo.
LikeLike
Is there any chance to have zip file for this code?
LikeLike