Difference between split/tap and choice/separate

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference between split/tap and choice/separate

ddimitrov
Looking at the documentation and implementations of DataflowReadChannel, I can not get the difference between the split/tap methods and between choice/separate. I browsed through the manual, but couldn't find anything there too.

Can anybody clarify please?

Thanks,
Dimitar
Reply | Threaded
Open this post in threaded view
|

Re: Difference between split/tap and choice/separate

Vaclav
Administrator
Dimitar,

tap - just like in unix shell passes a copy of each message that comes through the channel to a single supplied channel (e.g. for logging or debugging)
split - sends each incoming message to all output specified channels
choice - sends the incoming message to one of several output channels depending on the index returned by the supplied closure
separate - calls the supplied function with an incoming message as an argument expecting back a list of messages, each of which will be sent to the corresponding (by index) output channel

Details, although slightly outdated, in Java API doc - http://gpars.org/SNAPSHOT/javadoc/index.html

Vaclav



On Mon, Dec 3, 2012 at 2:06 AM, ddimitrov <[hidden email]> wrote:
Looking at the documentation and implementations of DataflowReadChannel, I
can not get the difference between the split/tap methods and between
choice/separate. I browsed through the manual, but couldn't find anything
there too.

Can anybody clarify please?

Thanks,
Dimitar



--
View this message in context: http://gpars-user-mailing-list.19372.n3.nabble.com/Difference-between-split-tap-and-choice-separate-tp4024758.html
Sent from the GPars - user mailing list mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
E-mail: [hidden email]
Blog: http://www.jroller.com/vaclav
Linkedin page: http://www.linkedin.com/in/vaclavpech
Reply | Threaded
Open this post in threaded view
|

Re: Difference between split/tap and choice/separate

ddimitrov
Thanks Václav, the difference between choice and separate is clear
now, but I am still confused about tap and choice. In particular, I
don't see physical copying of the messages (which is difficult to do
generically in Java anyway).

Looking at the implementation in the DataflowQueue, they look
virtually identical with the only difference that tap creates and
returns the sidechannel, while split accepts it as parameter. I.e. tap
can be rewritten as:

def tap() { def q = new DataflowQueue(); split(this, q); return q; }

Dimitar


On Tue, Dec 4, 2012 at 2:22 AM, Václav Pech <[hidden email]> wrote:

> Dimitar,
>
> tap - just like in unix shell passes a copy of each message that comes
> through the channel to a single supplied channel (e.g. for logging or
> debugging)
> split - sends each incoming message to all output specified channels
> choice - sends the incoming message to one of several output channels
> depending on the index returned by the supplied closure
> separate - calls the supplied function with an incoming message as an
> argument expecting back a list of messages, each of which will be sent to
> the corresponding (by index) output channel
>
> Details, although slightly outdated, in Java API doc -
> http://gpars.org/SNAPSHOT/javadoc/index.html
>
> Vaclav
>
>
>
> On Mon, Dec 3, 2012 at 2:06 AM, ddimitrov <[hidden email]>
> wrote:
>>
>> Looking at the documentation and implementations of DataflowReadChannel, I
>> can not get the difference between the split/tap methods and between
>> choice/separate. I browsed through the manual, but couldn't find anything
>> there too.
>>
>> Can anybody clarify please?
>>
>> Thanks,
>> Dimitar
>>
>>
>>
>> --
>> View this message in context:
>> http://gpars-user-mailing-list.19372.n3.nabble.com/Difference-between-split-tap-and-choice-separate-tp4024758.html
>> Sent from the GPars - user mailing list mailing list archive at
>> Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
>
>
> --
> E-mail: [hidden email]
> Blog: http://www.jroller.com/vaclav
> Linkedin page: http://www.linkedin.com/in/vaclavpech

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Difference between split/tap and choice/separate

Vaclav
Administrator


Looking at the implementation in the DataflowQueue, they look
virtually identical with the only difference that tap creates and
returns the sidechannel, while split accepts it as parameter. I.e. tap
can be rewritten as:

def tap() { def q = new DataflowQueue(); split(this, q); return q; }


Correct, tap() is a shortcut for the frequent scenario when you want to peek at the messages passing through the pipeline, while split() is more generic in that it allows for multiple output channels, not just two.


Vaclav


 
Dimitar


On Tue, Dec 4, 2012 at 2:22 AM, Václav Pech <[hidden email]> wrote:
> Dimitar,
>
> tap - just like in unix shell passes a copy of each message that comes
> through the channel to a single supplied channel (e.g. for logging or
> debugging)
> split - sends each incoming message to all output specified channels
> choice - sends the incoming message to one of several output channels
> depending on the index returned by the supplied closure
> separate - calls the supplied function with an incoming message as an
> argument expecting back a list of messages, each of which will be sent to
> the corresponding (by index) output channel
>
> Details, although slightly outdated, in Java API doc -
> http://gpars.org/SNAPSHOT/javadoc/index.html
>
> Vaclav
>
>
>
> On Mon, Dec 3, 2012 at 2:06 AM, ddimitrov <[hidden email]>
> wrote:
>>
>> Looking at the documentation and implementations of DataflowReadChannel, I
>> can not get the difference between the split/tap methods and between
>> choice/separate. I browsed through the manual, but couldn't find anything
>> there too.
>>
>> Can anybody clarify please?
>>
>> Thanks,
>> Dimitar
>>
>>
>>
>> --
>> View this message in context:
>> http://gpars-user-mailing-list.19372.n3.nabble.com/Difference-between-split-tap-and-choice-separate-tp4024758.html
>> Sent from the GPars - user mailing list mailing list archive at
>> Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
>
>
> --
> E-mail: [hidden email]
> Blog: http://www.jroller.com/vaclav
> Linkedin page: http://www.linkedin.com/in/vaclavpech

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
E-mail: [hidden email]
Blog: http://www.jroller.com/vaclav
Linkedin page: http://www.linkedin.com/in/vaclavpech