Coverage Report - org.apache.giraph.io.iterables.VertexReaderWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
VertexReaderWrapper
0%
0/14
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.io.iterables;
 20  
 
 21  
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 22  
 import org.apache.giraph.graph.Vertex;
 23  
 import org.apache.giraph.io.VertexReader;
 24  
 import org.apache.hadoop.io.Writable;
 25  
 import org.apache.hadoop.io.WritableComparable;
 26  
 import org.apache.hadoop.mapreduce.InputSplit;
 27  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 28  
 
 29  
 import java.io.IOException;
 30  
 
 31  
 /**
 32  
  * Wraps {@link GiraphReader} for vertices into {@link VertexReader}
 33  
  *
 34  
  * @param <I> Vertex id
 35  
  * @param <V> Vertex data
 36  
  * @param <E> Edge data
 37  
  */
 38  
 public class VertexReaderWrapper<I extends WritableComparable,
 39  
     V extends Writable, E extends Writable> extends VertexReader<I, V, E> {
 40  
   /** Wrapped vertex reader */
 41  
   private GiraphReader<Vertex<I, V, E>> vertexReader;
 42  
   /** {@link VertexReader}-like wrapper of {@link #vertexReader} */
 43  
   private IteratorToReaderWrapper<Vertex<I, V, E>> iterator;
 44  
 
 45  
   /**
 46  
    * Constructor
 47  
    *
 48  
    * @param vertexReader GiraphReader for vertices to wrap
 49  
    */
 50  0
   public VertexReaderWrapper(GiraphReader<Vertex<I, V, E>> vertexReader) {
 51  0
     this.vertexReader = vertexReader;
 52  0
     iterator = new IteratorToReaderWrapper<Vertex<I, V, E>>(vertexReader);
 53  0
   }
 54  
 
 55  
   @Override
 56  
   public void setConf(
 57  
       ImmutableClassesGiraphConfiguration<I, V, E> conf) {
 58  0
     super.setConf(conf);
 59  0
     conf.configureIfPossible(vertexReader);
 60  0
   }
 61  
 
 62  
   @Override
 63  
   public boolean nextVertex() throws IOException, InterruptedException {
 64  0
     return iterator.nextObject();
 65  
   }
 66  
 
 67  
   @Override
 68  
   public Vertex<I, V, E> getCurrentVertex() throws IOException,
 69  
       InterruptedException {
 70  0
     return iterator.getCurrentObject();
 71  
   }
 72  
 
 73  
   @Override
 74  
   public void initialize(InputSplit inputSplit,
 75  
       TaskAttemptContext context) throws IOException, InterruptedException {
 76  0
     vertexReader.initialize(inputSplit, context);
 77  0
   }
 78  
 
 79  
   @Override
 80  
   public void close() throws IOException {
 81  0
     vertexReader.close();
 82  0
   }
 83  
 
 84  
   @Override
 85  
   public float getProgress() throws IOException, InterruptedException {
 86  0
     return vertexReader.getProgress();
 87  
   }
 88  
 }