Coverage Report - org.apache.giraph.examples.GeneratedEdgeReader
 
Classes in this File Line Coverage Branch Coverage Complexity
GeneratedEdgeReader
0%
0/11
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.examples;
 20  
 
 21  
 import java.io.IOException;
 22  
 import org.apache.giraph.bsp.BspInputSplit;
 23  
 import org.apache.giraph.conf.LongConfOption;
 24  
 import org.apache.giraph.io.EdgeReader;
 25  
 import org.apache.hadoop.io.Writable;
 26  
 import org.apache.hadoop.io.WritableComparable;
 27  
 import org.apache.hadoop.mapreduce.InputSplit;
 28  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 29  
 
 30  
 /**
 31  
  * Used by GeneratedEdgeInputFormat
 32  
  * to read some generated data
 33  
  *
 34  
  * @param <I> Vertex index value
 35  
  * @param <E> Edge value
 36  
  */
 37  
 @SuppressWarnings("rawtypes")
 38  
 public abstract class GeneratedEdgeReader<
 39  
     I extends WritableComparable,
 40  
     E extends Writable>
 41  
     extends EdgeReader<I, E> {
 42  
   /** Default edges produced by this reader */
 43  0
   public static final LongConfOption DEFAULT_READER_EDGES =
 44  
     new LongConfOption("GeneratedEdgeReader.reader_edges", 10,
 45  
         "Default edges produced by this reader");
 46  
   /** Records read so far */
 47  0
   protected long recordsRead = 0;
 48  
   /** Total records to read (on this split alone) */
 49  0
   protected long totalRecords = 0;
 50  
   /** The input split from initialize(). */
 51  0
   protected BspInputSplit inputSplit = null;
 52  
 
 53  
   /**
 54  
    * Default constructor for reflection.
 55  
    */
 56  0
   public GeneratedEdgeReader() {
 57  0
   }
 58  
 
 59  
   @Override
 60  
   public final void initialize(InputSplit inputSplit,
 61  
       TaskAttemptContext context) throws IOException {
 62  0
     totalRecords = DEFAULT_READER_EDGES.get(getConf());
 63  0
     this.inputSplit = (BspInputSplit) inputSplit;
 64  0
   }
 65  
 
 66  
   @Override
 67  
   public void close() throws IOException {
 68  0
   }
 69  
 
 70  
   @Override
 71  
   public final float getProgress() throws IOException {
 72  0
     return recordsRead * 100.0f / totalRecords;
 73  
   }
 74  
 }