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

Do Once for For Each Record

  • 1.  Do Once for For Each Record

    Employee
    Posted 12-12-2014 17:57

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

    Originally posted by: ejones

    There have been a few times I've needed to execute a set of nodes multiple times. With the new looping nodes available in 5.1 this can finally be done. In the example graph the "Do While" node is wrapped in a custom library node that will execute the nodes once for each input record.
    Attachments:
    DoOnceForEachRecord.brg


  • 2.  RE: Do Once for For Each Record

    Employee
    Posted 12-17-2014 11:34

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

    Originally posted by: dstacey

    It's really great to see this functionality in Lavastorm - I'm sure it's going to be really useful. I really like the timeliness of the example too.

    Do you have any plans to release further documentation and/or examples around these new features to ensure we make the most of them. This would be much appreciated thanks.

    Dave


  • 3.  RE: Do Once for For Each Record

    Employee
    Posted 12-17-2014 15:29

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

    Originally posted by: ejones

    Thanks, that example was fun to put together.

    As far as examples and documentation. From the node editor you can click on node help. And there are examples of the looping node that are installed with LAE. Look in your Documents -> Public Documents -> Lavastorm BRAIN -> Examples folder. The graph is named IterationExample. The most interesting examples in that graph are the "File Producer" and "File Consumer" combination of nodes.

    I've been working more with looping over the last couple of days. Here are the things I've learned.
    - It is fair to think of the nodes involved with the loop as a sub-graph. There is no connection that can be made between those nodes and the rest of the nodes in the graph if you want it to work.
    - There is one, and only one, input to the loop which is the top input of the "Do While" node. There can be inputs to other nodes that are inside the loop, but they must be able to be available before the nodes in the loop need them and they will be the same value for each iteration.
    - There is one, and only one, output of the loop which is the top output of the "Do While" node.
    - The output from the bottom output of the "Do While" node comes from either the loop input data, or the bottom input. Both of those inputs should have the same structure.
    - The bottom input to the "Do While" contains what goes into the output of the loop. You can choose whether the output is an accumulation of everything or just the last set of data sent.
    - You can end the looping by sending zero records into the bottom input of the "Do While" but if you do that, and if you have not accumulated your output, you have zero records on the output.
    - If you really need an additional output of the loop, you'll have to write it using an "Output BRD File" node perhaps making it append multiple sets records to the one file. Then after the loop a "BRD File" node can read it.
    - If accumulating the output and you want to restart, you might have to drill inside the node, find the file that has been accumulating data and delete it. In this example on the first post above I added a feature that gives you another way to do it.

    Maybe all these things I've learned and written are correct, and if not, I hope someone corrects me on them. I'd like to see other people post what they've learned. I expect to come back and read this page when I need looping again to help refresh my memory as to how it works.
    Attachments:
    LoopExampleGraph.jpg


  • 4.  RE: Do Once for For Each Record

    Employee
    Posted 12-19-2014 10:31

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

    Originally posted by: ltolleson

    Great Information Ernest! Thanks for sharing.

    Larry


  • 5.  RE: Do Once for For Each Record

    Employee
    Posted 12-23-2014 08:23

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

    Originally posted by: dstacey

    Thanks - all the examples are really useful and I have been able to create my first graph that uses iteration successfully.

    What I'd really like to be able to do is create a graph that uses an outer loop whose subgraph in turn consists of an inner loop - so far this doesn't seem to work though. Do you know if this functionality is supported?

    Dave


  • 6.  RE: Do Once for For Each Record

    Employee
    Posted 01-02-2015 12:44

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

    Originally posted by: ejones

    I played with a loop within a loop and it didn't seem reliably. I had to monitor it and usually had to manually start each consecutive outer loop execution. Then for inexplicably it started running the loop on its own correctly. So a few thoughts on this:
    1. I do not know if it is supported, if I was in the process of uncovering a bug, or if it was some user error. When the looping finally ran and completed, I had my answer and have not yet needed to repeat the run.
    2. It may be possible to do the loop in such a way that it isn't a loop inside a loop. Maybe the outer loop and the inner loop can be combined into one loop. I haven't attempted this yet but it seems like it could be done.

    I've seen nothing that says whether or not it is supported. So I believe the best thing is to send any issue found with a loop within a loop to support and see what the response is.


  • 7.  RE: Do Once for For Each Record

    Employee
    Posted 01-05-2015 01:41

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

    Originally posted by: dstacey

    Thanks Ernest - I'll raise an issue to see if it is supported and let you all know what I find.


  • 8.  RE: Do Once for For Each Record

    Employee
    Posted 01-12-2015 14:23

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

    Originally posted by: ejones

    Update: Nested loops do work. You can go here for an example: http://community.lavastorm.com/threa...d-Nested-Loops

    In the cases where I had trouble getting the looping to finish, closing out the BRE session and reopening it seems to fix the issue.


  • 9.  RE: Do Once for For Each Record

    Employee
    Posted 01-21-2015 13:04

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

    Originally posted by: ejones

    The original "Do Once for Each Record" looping node above has an issue where after it finished all the iterations, it does one more iteration with zero records. When using this, that last iteration caused me some issues where I had to make my nodes handle the zero record case without failing. Today someone talked to me about this and explained the impossible situation this zero record iteration was causing.

    So, the version in this attachment works nearly the same way. The changes are:
    1. It adds another column to the output it is accumulating named RecordCount. This is the total number of records in the input stream.
    2. There is a new parameter in the node you can use to control the name of this field, but it is required because this is how it knows which iteration is the last one.
    Also. Some clocks were added to the demonstration of that node in the attached graph to make sure that all the nodes fire on every iteration.
    Attachments:
    DoOnceForEachRecord.brg


  • 10.  RE: Do Once for For Each Record

    Employee
    Posted 07-21-2015 07:51

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

    Originally posted by: igdoblan

    Hi,

    I have been trying to run the DoOnceForEachRecord.brg node you published some time ago, but I cannot get it working.

    I run a test and it worked ok. Then I have tried to run it multiple times and getting the same error again and again. It seems that is looking for a temporal brd file that doesn't exist. I have tried to create manually that file but then gets stuck.

    Attached there is a simple graph with the error.

    Regards
    Ignacio


    -- Errors for Do_While
    -- Errors for BRD_File
    ERROR: Unable to open input file c:/Lavastorm/LAETemp/tmp/outputAccum-55ae4d3e44431195.brd; the file does not exist.
    Error Code: lae.node.io.fileNotFound
    Attachments:
    error doforeachrecord graph.brg


  • 11.  RE: Do Once for For Each Record

    Employee
    Posted 07-21-2015 08:34

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

    Originally posted by: ejones

    Thanks, I tried unsuccessfully to reproduce the error with the graph you attached. It ran to completion successfully after making some changes:
    1. The IDB.brg file isn't available for me so I added a "Do for Each Record Node" that I had to the local library of the graph. I then used the local library version in place of the existing "Do For Each Record" node.
    2. The second output of the "Do For Each Record" node wasn't going anywhere when I opened it. And nothing was attached to the Filter node. So I attached those together
    3. I had to specify the directory in the "Append Excel" node.

    I did this using LAE 5.1. What version are you using? The version I ended up using is attached.
    Attachments:
    error doforeachrecord graph ej.brg


  • 12.  RE: Do Once for For Each Record

    Employee
    Posted 08-05-2015 02:38

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

    Originally posted by: igdoblan

    Thanks. I sorted this out using filter nodes to move all the files to a specific folder.

    Anyway, I will take a look at the graph.


  • 13.  RE: Do Once for For Each Record

    Employee
    Posted 09-10-2015 08:37

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

    Originally posted by: sdankner

    Your sample graph contains a base library, IDB. If you can send that I will take a look at this.