Coverage Report - org.apache.giraph.examples.MinimumIntCombiner
 
Classes in this File Line Coverage Branch Coverage Complexity
MinimumIntCombiner
100%
8/8
100%
4/4
3
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 package org.apache.giraph.examples;
 20  
 
 21  
 import org.apache.giraph.graph.VertexCombiner;
 22  
 import org.apache.hadoop.io.IntWritable;
 23  
 
 24  
 import java.io.IOException;
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * {@link VertexCombiner} that finds the minimum {@link IntWritable}
 30  
  */
 31  74
 public class MinimumIntCombiner
 32  
     extends VertexCombiner<IntWritable, IntWritable> {
 33  
   @Override
 34  
   public Iterable<IntWritable> combine(IntWritable target,
 35  
       Iterable<IntWritable> messages) throws IOException {
 36  71
     int minimum = Integer.MAX_VALUE;
 37  71
     for (IntWritable message : messages) {
 38  112
       if (message.get() < minimum) {
 39  85
         minimum = message.get();
 40  
       }
 41  
     }
 42  71
     List<IntWritable> value = new ArrayList<IntWritable>();
 43  71
     value.add(new IntWritable(minimum));
 44  
 
 45  71
     return value;
 46  
   }
 47  
 }