Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is an ArrayPort the appropriate solution here? #237

Closed
paulyoung opened this issue Jul 28, 2014 · 10 comments
Closed

Is an ArrayPort the appropriate solution here? #237

paulyoung opened this issue Jul 28, 2014 · 10 comments

Comments

@paulyoung
Copy link
Contributor

I have one component which sends a string on its NAME out port, and another component which accepts an array on its TASKS in port.

What would be the best way to take several NAME strings and send them to TASKS? Is the correct way to approach this by using an ArrayPort?

I believe I can do that by changing the datatype of TASKS from array to string, setting addressable to true, and doing the following in my graph:

... NAME -> TASKS[0] ...
... NAME -> TASKS[1] ...

If so, that leaves me with the following questions:

  • How do I set up the port and send values inside tests? Currently I have:
tasks = noflo.internalSocket.createSocket()
component.inPorts.tasks.attach tasks

tasks.send ['foo']
  • Does this affect how I'm using WirePattern? Current usage:
helpers.WirePattern component, config, (data, groups, outPort) ->
  # Here data.tasks is an array
@trustmaster
Copy link
Member

An array inPort would make sense if several components were connected to the same component and data processing would be somehow different depending on array index. It seems to me that what you are trying to do is just sending a sequence of strings to be processed independently. In this case it's just

Sender NAME -> TASKS Receiver

where Sender emits one name and Receiver processes one task per invocation.

An addressable port makes sense here if Sender emits several names per invocation and those are combined per Receiver invocation, e.g. Receiver uses TASKS[0], [1], [2] and [3] to produce a single output packet.

As for WirePattern, it doesn't have any specific support for addressable ports, i.e. it deals with ports regardless of array index.

@paulyoung
Copy link
Contributor Author

Thanks for the insight. I actually want to perform an operation on the array as a whole.

A contrived example would be something like this:

Take multiple NAMEs (each from different processes) and pass them all to the TASKS port as an array, where internally that component would count the number of tasks in the list.

@trustmaster
Copy link
Member

So, it actually looks like:

Sender0 NAME -> TASKS[0] Receiver
Sender1 NAME -> TASKS[1] Receiver

Is it important that all 0...N names should arrive at TASKS port for Receiver to do something with the array?

@ever-null
Copy link
Contributor

@paulyoung This may be a starting point for that requirement: http://noflojs.org/component/noflo-adapters-PacketsToArray/

I cannot say whether PacketsToArray is up-to-date with the latest changes, but its worth the look.

@trustmaster
Copy link
Member

@hayesmg PacketsToArray cannot be used here because data is coming from several senders, each sending a disconnect after a data packet.

@ever-null
Copy link
Contributor

I see what you're saying @trustmaster. The connect/send/disconnect of upstream ports invalidates the use of that component.

@paulyoung
Copy link
Contributor Author

Is it important that all 0...N names should arrive at TASKS port for Receiver to do something with the array?

@trustmaster yes, that's correct.

@trustmaster
Copy link
Member

@paulyoung then either an addressable port is needed here (which is not settled in WirePattern yet, see #240), or a Merge component that would merge packets arriving at inputs 0...N to a single output port as a sequence of N data packets followed by a disconnect, then PacketsToArray can be chained after such a Merge node.

@paulyoung
Copy link
Contributor Author

An addressable port would be preferred over an intermediate component since that provides an nicer API.

I may be getting confused with the history of NoFlo. Is the old way to use ArrayPort and the current way to set addressable: true?

@bergie
Copy link
Member

bergie commented Jul 29, 2014

@paulyoung yep, ArrayPort is the old port API and addressable is the new, post-0.5 port API. It is still an "array port" in FBP terminology, though

@bergie bergie closed this as completed Jul 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants