| ivan stojic | |||
| life is a low fidelity experience | |||
![]() |
|||
|
|
Collating data sets in TIBCO BusinessWorksMarch 23rd, 2006, 16:47.There are several ways one can collate two data sets in BusinessWorks. Supposing that they have some 1-n relationship, you could either do it by using iteration groups or by letting XPath do it for you. Which approach is better? Let’s find out! First, let us introduce the example data structure
The second structure is called Person. Each person has his or her id, name and the dunning level to which they should be set. These two structures together form a 1-n relationship, with the Dunning element being on the 1 side, while the Person element represents the n side. The first option to do the data collation is to have two iteration groups, one inside the other. The outer group will iterate over Dunning elements, and the inner group will iterate over Person elements. Inside the inner group we will check if this specific Person is part of the current Dunning level, and if that is the case we shall take some sort of an action. Figure 1 - Solution using nested groups
Unfortunately for us, this solution requires a lot of time to execute. It is as complex as traversing through as many records as there are in the Cartesian product of the two data sets. This kind of searching is also used in database queries where a join is used on tables that don’t have the join fields indexed. In this context it is more commonly known as table scanning. The second possibility for solving this situation is to use a Mapper activity. We reorganize the data model slightly in the Mapper activity and then let XPath do the data merging for us. The core of this solution lies in the fact that XPath can do implicitly what we have done explicitly in the previous version of the solution. Though we still use two iteration groups to display the data, they are no longer traversing a Cartesian product of the data, but only exactly as many rows as there are in the sum of both data sets. Figure 2 - Solution using XPath
Using filtering expressions, we can pick up just those Person elements which have the dunning level set to the dunning level of a certain Dunning element. Here is how the data looks and how it is mapped in the Mapper activity. Figure 3 - The core of the XPath based solution
There are two things of note happening here. The output model of the Mapper has been slightly changed from the data model we have introduced at the start. We have moved the repeating structure of Person elements into the Dunning element. This structure will hold those Person entries which belong to the given Dunning element. The secret component lies in the way we have used XPath’s for-each iteration combined with path filtering. As you can see in figure 3, the result Person structure is a set composed of those elements of the input Person structure which satisfy a path filter. In this case, the path filter specifies that we want those members of the original Person structure that have their dunning parameter set to the same value of the id of the Dunning element through which we are currently traversing with the outer for-each iteration. One usually uses the path filtering to access individual members of a repeatable structure based on their index. However, you can also access elements based on their values or attributes. In my testing of this implementation I have discovered that using the XPath based implementation you can get slightly more than an order of magnitute in speed gain. For those of you using AE5, I’m offering a download of the repository containing the example which was described above. 3 responses to "Collating data sets in TIBCO BusinessWorks"Sreenivasulu Gandhavalla:hi permalink.. its good one.. Sandeep: Hey man, Lets discuss if you have some hardtime with TIBCO.I am also a Tibco Integration Specialist working in United States. Reply! Bye Ivans. Sanjiv Gupta: Hi, I liked the website and appreciate your inputs. Sanjiv
Leave a Reply |
|