Coverage Report - org.apache.giraph.lib.SequenceFileVertexInputFormat
 
Classes in this File Line Coverage Branch Coverage Complexity
SequenceFileVertexInputFormat
0%
0/5
N/A
1
SequenceFileVertexInputFormat$SequenceFileVertexReader
0%
0/10
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  
 package org.apache.giraph.lib;
 19  
 
 20  
 import org.apache.giraph.graph.BasicVertex;
 21  
 import org.apache.giraph.graph.VertexInputFormat;
 22  
 import org.apache.giraph.graph.VertexReader;
 23  
 import org.apache.hadoop.io.Writable;
 24  
 import org.apache.hadoop.io.WritableComparable;
 25  
 import org.apache.hadoop.mapreduce.InputSplit;
 26  
 import org.apache.hadoop.mapreduce.JobContext;
 27  
 import org.apache.hadoop.mapreduce.RecordReader;
 28  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 29  
 import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
 30  
 
 31  
 import java.io.IOException;
 32  
 import java.util.List;
 33  
 
 34  
 /**
 35  
  * Sequence file vertex input format based on {@link SequenceFileInputFormat}.
 36  
  *
 37  
  * @param <I> Vertex id
 38  
  * @param <V> Vertex data
 39  
  * @param <E> Edge data
 40  
  * @param <M> Message data
 41  
  * @param <X> Value type
 42  
  */
 43  
 @SuppressWarnings("rawtypes")
 44  0
 public class SequenceFileVertexInputFormat<I extends WritableComparable,
 45  
     V extends Writable, E extends Writable, M extends Writable,
 46  
     X extends BasicVertex<I, V, E, M>>
 47  
     extends VertexInputFormat<I, V, E, M> {
 48  
   /** Internal input format */
 49  0
   protected SequenceFileInputFormat<I, X> sequenceFileInputFormat =
 50  
     new SequenceFileInputFormat<I, X>();
 51  
 
 52  
   @Override
 53  
   public List<InputSplit> getSplits(JobContext context, int numWorkers)
 54  
     throws IOException, InterruptedException {
 55  0
     return sequenceFileInputFormat.getSplits(context);
 56  
   }
 57  
 
 58  
   @Override
 59  
   public VertexReader<I, V, E, M> createVertexReader(InputSplit split,
 60  
       TaskAttemptContext context) throws IOException {
 61  0
     return new SequenceFileVertexReader<I, V, E, M, X>(
 62  
         sequenceFileInputFormat.createRecordReader(split, context));
 63  
   }
 64  
 
 65  
   /**
 66  
    * Vertex reader used with {@link SequenceFileVertexInputFormat}.
 67  
    *
 68  
    * @param <I> Vertex id
 69  
    * @param <V> Vertex data
 70  
    * @param <E> Edge data
 71  
    * @param <M> Message data
 72  
    * @param <X> Value type
 73  
    */
 74  0
   public static class SequenceFileVertexReader<I extends WritableComparable,
 75  
       V extends Writable, E extends Writable, M extends Writable,
 76  
       X extends BasicVertex<I, V, E, M>>
 77  
       implements VertexReader<I, V, E, M> {
 78  
     /** Internal record reader from {@link SequenceFileInputFormat} */
 79  
     private final RecordReader<I, X> recordReader;
 80  
 
 81  
     /**
 82  
      * Constructor with record reader.
 83  
      *
 84  
      * @param recordReader Reader from {@link SequenceFileInputFormat}.
 85  
      */
 86  0
     public SequenceFileVertexReader(RecordReader<I, X> recordReader) {
 87  0
       this.recordReader = recordReader;
 88  0
     }
 89  
 
 90  
     @Override public void initialize(InputSplit inputSplit,
 91  
         TaskAttemptContext context) throws IOException, InterruptedException {
 92  0
       recordReader.initialize(inputSplit, context);
 93  0
     }
 94  
 
 95  
     @Override public boolean nextVertex() throws IOException,
 96  
         InterruptedException {
 97  0
       return recordReader.nextKeyValue();
 98  
     }
 99  
 
 100  
     @Override public BasicVertex<I, V, E, M> getCurrentVertex()
 101  
       throws IOException, InterruptedException {
 102  0
       return recordReader.getCurrentValue();
 103  
     }
 104  
 
 105  
 
 106  
     @Override public void close() throws IOException {
 107  0
       recordReader.close();
 108  0
     }
 109  
 
 110  
     @Override public float getProgress() throws IOException,
 111  
         InterruptedException {
 112  0
       return recordReader.getProgress();
 113  
     }
 114  
   }
 115  
 }