5.3.2.5. Overcoming the Limitations of N-Way Multithread Sections

<< Click to Display Table of Contents >>

Navigation:  5. Detailed description of the Actions > 5.3. Run Control > 5.3.2. Multithread Run >

5.3.2.5. Overcoming the Limitations of N-Way Multithread Sections

 

If we have the following Anatella Graph:

 

clip0053

We have a transaction-table, where each row represents one transaction: “How many items of product A or B did the customer X buy?”. Using the ANATEL~3_img69 “Flatten” Action, we transform this transaction-table into a Customer-table (where each row represents a customer).

The ANATEL~3_img69 “Flatten” Action reads the “CustomerID” column in the table on the input pin 0 and, each time the “CustomerID” column changes, it ouputs one row containing all the data about this “CustomerID”. If we execute the ANATEL~3_img69 “Flatten” Action inside a N-Way Section, we’ll have:

 

clip0054

 
The above graph is equivalent to the following “conceptual” graph:

 

ANATEL~3_img73

 

With the default settings, The ANATEL~3_img69 “Flatten” Action is not working properly inside a N-Way section. We will now see how to correct this situation.

 

Let’s now define “Branch 1” and “Branch 2”in the following way:

 

clip0057

 

In the above example, the ANATEL~3_img69 “Flatten” Action inside “Branch 1” receives only a fraction of the rows related to a specific customer (e.g. For the “CostumerID=1”, it receives only the row about the “A” product and nothing about the “B’ product). It thus produced a wrong result (e.g. for the “CostumerID=1”, it outputs only the quantity of A product and nothing for the B product). In order for the The ANATEL~3_img69 “Flatten” Action inside “Branch 1” to work properly, it should receive all the rows related to a specific customer (e.g. it should receive all the rows related to the “CustomerID=1”). With the default settings, the rows that enter into the first ANATEL~3_img5Multithread Action are forwarded more-or-less randomly to either “Branch 1” or “Branch 2”. To guarantee that all the rows related to the same customer are going inside the same branch, we must use the “partitioning” parameter number1 of the ANATEL~3_img5Multithread Action: For example, this will work properly:

 

clip0055

The “partitioning” parameter basically says to the first ANATEL~3_img5Multithread Action: “Continue to send the input rows to the same branch, as long as the CostumerID stays the same” (Beware: please note that this “partitioning” parameter is set in the parameter panel of the second ANATEL~3_img5Multithread Action). Thanks to the “partitioning” parameter, we can run in parallel an even larger variety of Actions (such as the ANATEL~3_img69 “Flatten” Action, the clip0056 Aggregate Action, the clip0058 Partitioned Sort Action, the ANATEL~3_img91 kpi_Stock Action, etc.).

 

To know more about how to overcome the limitations of the N-Way Multithread Section, please refer to section “5.5.5.2. Using the “out-of-memory mode” of the clip0056 Aggregate Action inside a N-Way Multithreaded Section”.