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