# building a Flow graph to work with chunks of data ?

## building a Flow graph to work with chunks of data ?

After reading it and after I have seen some practical examples, I haven't found a solution to my problem yet.

My input: a set of value that I get altogether on a given timing, for example I get an array of int any tot. seconds.

My logic: so my input is an array but my application/algorithm it's not supposed to work on that array but on a bigger chunk of data like a set of array ordered in a sequence ( to keep the input order ).

My abstract solution is to imagine that I have this flow of array in input, and even if I know that I get 1 array each 50 seconds I don't want to rely on time to group this arrays in a chunk of data, instead I just would like to set a value used in a buffer node to aggregate this arrays in a single output, for example if I set 10, the node waits until 10 arrays are ready in a sequence and then it will fires the data over the graph.

My problem also hides a change in the roots of my flow graph, if it's true that my input is N, my real input for my internal business logic is kN, so that node buffer should be the first block on the input and it also should "repack" my data to be considered or referenced more easily by the other functions, because internally I need to consider chunks of arrays not just a single array.

In the entire TBB I haven't found a block for a graph that actually changes the dimension of my input and gives me the ability to refere to my input as a chunk, How do I solve my problem with a flow graph ?

It would be great to also have the ability to access the next or the previous k inputs in sequence, according to the input order, from a function node or from any given node.

4 post / 0 new
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Well, at this point I suppose that there is no answer to my question or it's not possible to do that ?

Hi,

If you would like to change the "shape" of your input (making a group of 1-D arrays into a 2-D array, or aggregating a set of arrays into a single array), the easiest way to do this is a multifunction_node.  (Notice the name was changed from the Dr. Dobbs article.)

The multifunction_node takes inputs and produces zero or more outputs on one or more output ports.  So it is possible for a multifunction_node to accept an input and produce no output, or multiple outputs, depending.

For example you could create a multifunction_node that accepts pointers to vectors, queueing the values up and when some criterion has been satisfied passes the data on to another node.  I am attaching a simple program that illustrates this.

The memory management is not in there; you would need to figure how to free up the vectors being passed tot he multifunction_node.  In a real program you could pass the received vectors on to another output port of the multifunction_node and re-use them, but that would have obfuscated the thing I was trying to show.  You can get the idea from the program.

I hope I understood your problem correctly.  If you have questions, please let me know.

Regards, Chris

## Allegati:

AllegatoDimensione
2.63 KB

One comment; the multifunction_node is serial because the vectors has no synchronization, so we need another way to maintain its consistency.