Coverage Report - org.apache.giraph.graph.AggregatorWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
AggregatorWriter
N/A
N/A
1
 
 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.graph;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.util.Map.Entry;
 23  
 
 24  
 import org.apache.hadoop.io.Writable;
 25  
 import org.apache.hadoop.mapreduce.Mapper.Context;
 26  
 
 27  
 /**
 28  
  *  An AggregatorWriter is used to export Aggregators during or at the end of
 29  
  *  each computation. It runs on the master and it's called at the end of each
 30  
  *  superstep. The special signal {@link AggregatorWriter#LAST_SUPERSTEP} is
 31  
  *  passed to {@link AggregatorWriter#writeAggregator(Iterable, long)} as the
 32  
  *  superstep value to signal the end of computation.
 33  
  */
 34  
 public interface AggregatorWriter {
 35  
   /** Signal for last superstep */
 36  
   int LAST_SUPERSTEP = -1;
 37  
 
 38  
   /**
 39  
    * The method is called at the initialization of the AggregatorWriter.
 40  
    * More precisely, the aggregatorWriter is initialized each time a new
 41  
    * master is elected.
 42  
    *
 43  
    * @param context Mapper Context where the master is running on
 44  
    * @param applicationAttempt ID of the applicationAttempt, used to
 45  
    *        disambiguate aggregator writes for different attempts
 46  
    * @throws IOException
 47  
    */
 48  
   @SuppressWarnings("rawtypes")
 49  
   void initialize(Context context, long applicationAttempt) throws IOException;
 50  
 
 51  
   /**
 52  
    * The method is called at the end of each superstep. The user might decide
 53  
    * whether to write the aggregators values for the current superstep. For
 54  
    * the last superstep, {@link AggregatorWriter#LAST_SUPERSTEP} is passed.
 55  
    *
 56  
    * @param aggregatorMap Map from aggregator name to aggregator value
 57  
    * @param superstep Current superstep
 58  
    * @throws IOException
 59  
    */
 60  
   void writeAggregator(
 61  
       Iterable<Entry<String, Writable>> aggregatorMap,
 62  
       long superstep) throws IOException;
 63  
 
 64  
   /**
 65  
    * The method is called at the end of a successful computation. The method
 66  
    * is not called when the job fails and a new master is elected. For this
 67  
    * reason it's advised to flush data at the end of
 68  
    * {@link AggregatorWriter#writeAggregator(Iterable, long)}.
 69  
    *
 70  
    * @throws IOException
 71  
    */
 72  
   void close() throws IOException;
 73  
 }