Coverage Report - org.apache.giraph.bsp.BspOutputFormat
 
Classes in this File Line Coverage Branch Coverage Complexity
BspOutputFormat
100%
12/12
100%
4/4
2.333
 
 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.bsp;
 20  
 
 21  
 import java.io.IOException;
 22  
 
 23  
 import org.apache.giraph.graph.BspUtils;
 24  
 import org.apache.hadoop.io.Text;
 25  
 import org.apache.hadoop.mapreduce.JobContext;
 26  
 import org.apache.hadoop.mapreduce.OutputCommitter;
 27  
 import org.apache.hadoop.mapreduce.OutputFormat;
 28  
 import org.apache.hadoop.mapreduce.RecordWriter;
 29  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 30  
 import org.apache.log4j.Logger;
 31  
 
 32  
 /**
 33  
  * This is for internal use only.  Allows the vertex output format routines
 34  
  * to be called as if a normal Hadoop job.
 35  
  */
 36  48
 public class BspOutputFormat extends OutputFormat<Text, Text> {
 37  
   /** Class logger */
 38  1
   private static Logger LOG = Logger.getLogger(BspOutputFormat.class);
 39  
 
 40  
   @Override
 41  
   public void checkOutputSpecs(JobContext context)
 42  
     throws IOException, InterruptedException {
 43  24
     if (BspUtils.getVertexOutputFormatClass(context.getConfiguration()) ==
 44  
         null) {
 45  7
       LOG.warn("checkOutputSpecs: ImmutableOutputCommiter" +
 46  
           " will not check anything");
 47  7
       return;
 48  
     }
 49  17
     BspUtils.createVertexOutputFormat(context.getConfiguration()).
 50  
       checkOutputSpecs(context);
 51  17
   }
 52  
 
 53  
   @Override
 54  
   public OutputCommitter getOutputCommitter(TaskAttemptContext context)
 55  
     throws IOException, InterruptedException {
 56  24
     if (BspUtils.getVertexOutputFormatClass(context.getConfiguration()) ==
 57  
         null) {
 58  7
       LOG.warn("getOutputCommitter: Returning " +
 59  
           "ImmutableOutputCommiter (does nothing).");
 60  7
       return new ImmutableOutputCommitter();
 61  
     }
 62  17
     return BspUtils.createVertexOutputFormat(context.getConfiguration()).
 63  
         getOutputCommitter(context);
 64  
   }
 65  
 
 66  
   @Override
 67  
   public RecordWriter<Text, Text> getRecordWriter(TaskAttemptContext context)
 68  
     throws IOException, InterruptedException {
 69  24
     return new BspRecordWriter();
 70  
   }
 71  
 }