Coverage Report - org.apache.giraph.examples.GeneratedVertexReader
 
Classes in this File Line Coverage Branch Coverage Complexity
GeneratedVertexReader
0%
0/13
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 org.apache.giraph.bsp.BspInputSplit;
 22  
 import org.apache.giraph.conf.BooleanConfOption;
 23  
 import org.apache.giraph.conf.LongConfOption;
 24  
 import org.apache.giraph.io.VertexReader;
 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  
 import java.io.IOException;
 31  
 
 32  
 /**
 33  
  * Used by GeneratedVertexInputFormat to read some generated data
 34  
  *
 35  
  * @param <I> Vertex index value
 36  
  * @param <V> Vertex value
 37  
  * @param <E> Edge value
 38  
  */
 39  
 @SuppressWarnings("rawtypes")
 40  
 public abstract class GeneratedVertexReader<
 41  
     I extends WritableComparable, V extends Writable,
 42  
     E extends Writable>
 43  
     extends VertexReader<I, V, E> {
 44  
   /** Vertices produced by this reader */
 45  0
   public static final LongConfOption READER_VERTICES =
 46  
       new LongConfOption("GeneratedVertexReader.reader_vertices", 10,
 47  
           "Vertices produced by this reader");
 48  
   /** Reverse the order of the vertices? */
 49  0
   public static final BooleanConfOption REVERSE_ID_ORDER =
 50  
       new BooleanConfOption("GeneratedVertexReader.reverseIdOrder", false,
 51  
           "Reverse the order of the vertices?");
 52  
   /** Records read so far */
 53  0
   protected long recordsRead = 0;
 54  
   /** Total records to read (on this split alone) */
 55  0
   protected long totalRecords = 0;
 56  
   /** The input split from initialize(). */
 57  0
   protected BspInputSplit inputSplit = null;
 58  
   /** Reverse the id order? */
 59  
   protected boolean reverseIdOrder;
 60  
 
 61  
   /**
 62  
    * Default constructor for reflection.
 63  
    */
 64  0
   public GeneratedVertexReader() {
 65  0
   }
 66  
 
 67  
   @Override
 68  
   public final void initialize(InputSplit inputSplit,
 69  
       TaskAttemptContext context) throws IOException {
 70  0
     totalRecords = GeneratedVertexReader.READER_VERTICES.get(getConf());
 71  0
     reverseIdOrder = GeneratedVertexReader.REVERSE_ID_ORDER.get(getConf());
 72  0
     this.inputSplit = (BspInputSplit) inputSplit;
 73  0
   }
 74  
 
 75  
   @Override
 76  
   public void close() throws IOException {
 77  0
   }
 78  
 
 79  
   @Override
 80  
   public final float getProgress() throws IOException {
 81  0
     return recordsRead * 100.0f / totalRecords;
 82  
   }
 83  
 }