you can check the combiner used by the shortest paths algorithm, that has
the inverted semantics as yours, as it is using the minimum value.


On Mon, May 12, 2014 at 8:03 AM, nishant gandhi
<nishantgandh...@gmail.com>wrote:

> Let say I have 5 nodes which are sending message to 6th node.
> each 5 node sending one message to 6th node containing some value.
> I want to intercept all those 5 messages going towards 6th node.
> after that I want to find the maximum value contained among those 5 nodes.
> and send single message from combiner to 6th node which contain only the
> maximum value among those messages.
>
>
> I have tried to write a simple code for it but it seems not working. I
> dont know what I am doing wrong.
>
> In the code below, node 0 trying to send 3 message to node 1.
> My final goal is, in superstep=1, node 1 should receive only one message
> with contain 4 only.
> My current code receiving all the 3 messages and hence I am getting final
> value of variable:"test" as 7.
>
>
> public class CombinerTest extends BasicComputation<LongWritable,
> DoubleWritable, FloatWritable,DoubleWritable>
>  {
>
>     @Override
>     public void compute(Vertex<LongWritable, DoubleWritable,
> FloatWritable> arg0,Iterable<DoubleWritable> arg1) throws IOException {
>
>
>
>         if(getSuperstep()==0 && (arg0.getId().get()==0))
>         {
>             sendMessage(new LongWritable(1),new DoubleWritable(1));
>             sendMessage(new LongWritable(1),new DoubleWritable(2));
>             sendMessage(new LongWritable(1),new DoubleWritable(4));
>         }
>         DoubleWritable test=new DoubleWritable(0);
>         if(getSuperstep()==1)
>         {
>             for(DoubleWritable messages :arg1)
>             {
>                     test.set(test.get()+messages.get());
>                 //    changed=true;
>             }
>             arg0.setValue(test);
>         }
>         arg0.voteToHalt();
>     }
>
>     public void combine(LongWritable vertexIndex, DoubleWritable
> originalMessage, DoubleWritable messageToCombine)
>     {
>             if(originalMessage.get() > messageToCombine.get())
>             {
>               originalMessage.set(messageToCombine.get());
>             }
>     }
>      public DoubleWritable createInitialMessage()
>      {
>             return new DoubleWritable(Double.MAX_VALUE);
>      }
>
>
> }
>
>
>
>
> please help me to figure out correct way to write code.
> Thanks Maria.
>
> Nishant Gandhi
> M.Tech. CSE
> IIT Patna
>
>
> On Mon, May 12, 2014 at 11:11 AM, Maria Stylianou <mars...@gmail.com>wrote:
>
>> Hi Nishant,
>>
>> Can you be more specific? Are you trying to combine all incoming messages
>> of a vertex into one message? What do you mean combine? Add values? Or
>> append to a list?
>> The message can be a list so you can put all values together.
>>
>> Maria
>>
>>
>> On Sunday, May 11, 2014, nishant gandhi <nishantgandh...@gmail.com>
>> wrote:
>>
>>> Hi,
>>> I am trying to write code that use Combiner. I want to combine all
>>> message into one for each vertex. That one message contains message value
>>> bigger than all the other message values.
>>> Please help.
>>>
>>> Nishant Gandhi
>>> M.Tech. CSE
>>> IIT Patna
>>>
>>
>>
>> --
>> Sent from Android Mobile
>>
>
>


-- 
   Claudio Martella

Reply via email to