LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  recursive logic implement

    Employee
    Posted 05-06-2015 00:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rakhi

    how could we abel to implement recursive logic using lavastorm. our input data is
    EMP_ID:string,MGR_ID:string,EMP_NAME:string
    28000,,MARK
    28001,28000,STIVE
    28002,28000,ANNA
    28003,28001,LORENA
    28004,28001,SIMON
    28005,28003,PATRICK
    28006,28005,ZOYA
    28007,28002,PETER
    28008,28002,PAUL
    we needs find out the ZOYA's direct and indirect manageer hierachy from the input dataset and output will be like below.

    EMP_ID,MGR_ID,EMP_NAME
    28006,28005,PATRICK
    28006,28003,LORENA
    28006,28001,STIVE
    28006,28000,MARK
    please let us know and it is very urgent requiremet for us.
    Thanks in advance.


  • 2.  RE: recursive logic implement

    Employee
    Posted 05-06-2015 06:28

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Try something like the attached. I've just outputted the ID's. You can use a Look Up to get the names. Also, for each hierachy, it ends in an extra record where the MGR_ID is blank. You can easily remove those records. For me, it makes it easy to see where the chain ends.
    Attachments:
    hierarchy.brg


  • 3.  RE: recursive logic implement

    Employee
    Posted 05-06-2015 07:57

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    What ryeh is probably the fastest way of doing it. In the attached graph are two additional options.

    The first is a "brute force" method that runs slower but by spreading the logic over more nodes the logic might be easier to follow. This "brute force" method usually works with reporting hierarchies since there is usually a clear limit as to how many levels the hierarchy will ever have. And, as is done with the "Meta Check" node, you can have the graph warn you if the number of levels is more than expected so you can go add support for an additional level.

    The second uses a looping node and will go as deep as the data supports. One danger here is that if there is a loop in the reporting hierarchy the graph will never complete on its own until it slowly uses up all the disk space and fails, or you notice that it hasn't completed in a day or so and stop it. I suppose a way to check for an infinite loop during the run is to read all the accumulated data and looking for duplication where you have more than one record showing an employee reporting to the same manager. Adding this will slow the iterations down considerably but would make it more resilient.
    Attachments:
    ReportingHerarchyExample.brg


  • 4.  RE: recursive logic implement

    Employee
    Posted 05-06-2015 08:46

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    To add to what Roger and Ernest said.. the looping node might get into trouble if any person in the tree reports to themselves. This often happens with senior managers or CEOs.. your logic needs to watch for such circular connections.


  • 5.  RE: recursive logic implement

    Employee
    Posted 05-06-2015 22:56

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rakhi

    Thanks for the solution but we needs to do it LAE 4.5 version. Please suggest us.