Coverage Report - org.apache.giraph.io.iterables.MappingReaderWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
MappingReaderWrapper
0%
0/14
N/A
0
 
 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.io.MappingReader;
 23  
 import org.apache.giraph.mapping.MappingEntry;
 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 mapping into
 33  
  * {@link org.apache.giraph.io.MappingReader}
 34  
  *
 35  
  * @param <I> vertexId type
 36  
  * @param <V> vertexValue type
 37  
  * @param <E> edgeValue type
 38  
  * @param <B> mappingTarget type
 39  
  */
 40  
 public class MappingReaderWrapper<I extends WritableComparable,
 41  
   V extends Writable, E extends  Writable, B extends Writable>
 42  
   extends MappingReader<I, V, E, B> {
 43  
   /** Wrapped mapping reader */
 44  
   private GiraphReader<MappingEntry<I, B>> mappingReader;
 45  
   /**
 46  
    * {@link org.apache.giraph.io.MappingReader}-like wrapper of
 47  
    * {@link #mappingReader}
 48  
    */
 49  
   private IteratorToReaderWrapper<MappingEntry<I, B>> iterator;
 50  
 
 51  
   /**
 52  
    * Constructor
 53  
    *
 54  
    * @param mappingReader user supplied mappingReader
 55  
    */
 56  0
   public MappingReaderWrapper(GiraphReader<MappingEntry<I, B>> mappingReader) {
 57  0
     this.mappingReader = mappingReader;
 58  0
     iterator = new IteratorToReaderWrapper<>(mappingReader);
 59  0
   }
 60  
 
 61  
   @Override
 62  
   public void setConf(
 63  
       ImmutableClassesGiraphConfiguration<I, V, E> conf) {
 64  0
     super.setConf(conf);
 65  0
     conf.configureIfPossible(mappingReader);
 66  0
   }
 67  
 
 68  
   @Override
 69  
   public boolean nextEntry() throws IOException, InterruptedException {
 70  0
     return iterator.nextObject();
 71  
   }
 72  
 
 73  
   @Override
 74  
   public MappingEntry<I, B> getCurrentEntry()
 75  
     throws IOException, InterruptedException {
 76  0
     return iterator.getCurrentObject();
 77  
   }
 78  
 
 79  
 
 80  
   @Override
 81  
   public void initialize(InputSplit inputSplit,
 82  
     TaskAttemptContext context) throws IOException, InterruptedException {
 83  0
     mappingReader.initialize(inputSplit, context);
 84  0
   }
 85  
 
 86  
   @Override
 87  
   public void close() throws IOException {
 88  0
     mappingReader.close();
 89  0
   }
 90  
 
 91  
   @Override
 92  
   public float getProgress() throws IOException, InterruptedException {
 93  0
     return mappingReader.getProgress();
 94  
   }
 95  
 }