Coverage Report - org.apache.giraph.io.internal.WrappedMappingReader
 
Classes in this File Line Coverage Branch Coverage Complexity
WrappedMappingReader
0%
0/17
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.internal;
 20  
 
 21  
 import java.io.IOException;
 22  
 
 23  
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 24  
 import org.apache.giraph.io.MappingReader;
 25  
 import org.apache.giraph.job.HadoopUtils;
 26  
 import org.apache.giraph.mapping.MappingEntry;
 27  
 import org.apache.giraph.worker.WorkerGlobalCommUsage;
 28  
 import org.apache.hadoop.io.Writable;
 29  
 import org.apache.hadoop.io.WritableComparable;
 30  
 import org.apache.hadoop.mapreduce.InputSplit;
 31  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 32  
 
 33  
 /**
 34  
  * For internal use only.
 35  
  *
 36  
  * Wraps {@link org.apache.giraph.io.MappingReader} to make sure proper
 37  
  * configuration parameters are passed around, that parameters set in original
 38  
  * configuration are available in methods of this reader
 39  
  *
 40  
  * @param <I> vertexId type
 41  
  * @param <V> vertexValue type
 42  
  * @param <E> edgeValue type
 43  
  * @param <B> mappingTarget type
 44  
  */
 45  
 public class WrappedMappingReader<I extends WritableComparable,
 46  
   V extends Writable, E extends Writable, B extends Writable>
 47  
   extends MappingReader<I, V, E, B> {
 48  
   /** User set baseMappingReader wrapped over */
 49  
   private final MappingReader<I, V, E, B> baseMappingReader;
 50  
 
 51  
   /**
 52  
    * Constructor
 53  
    *
 54  
    * @param baseMappingReader User set baseMappingReader
 55  
    * @param conf configuration
 56  
    */
 57  
   public WrappedMappingReader(MappingReader<I, V, E, B> baseMappingReader,
 58  0
     ImmutableClassesGiraphConfiguration<I, V, E> conf) {
 59  0
     this.baseMappingReader = baseMappingReader;
 60  0
     super.setConf(conf);
 61  0
     baseMappingReader.setConf(conf);
 62  0
   }
 63  
 
 64  
   @Override
 65  
   public void setConf(
 66  
       ImmutableClassesGiraphConfiguration<I, V, E> conf) {
 67  
     // We don't want to use external configuration
 68  0
   }
 69  
 
 70  
   @Override
 71  
   public void initialize(InputSplit inputSplit,
 72  
     TaskAttemptContext context) throws IOException, InterruptedException {
 73  0
     baseMappingReader.initialize(inputSplit,
 74  0
         HadoopUtils.makeTaskAttemptContext(getConf(), context));
 75  0
   }
 76  
 
 77  
   @Override
 78  
   public void setWorkerGlobalCommUsage(WorkerGlobalCommUsage usage) {
 79  0
     super.setWorkerGlobalCommUsage(usage);
 80  
     // Set global communication usage for edge reader
 81  0
     baseMappingReader.setWorkerGlobalCommUsage(usage);
 82  0
   }
 83  
 
 84  
   @Override
 85  
   public boolean nextEntry() throws IOException, InterruptedException {
 86  0
     return baseMappingReader.nextEntry();
 87  
   }
 88  
 
 89  
   @Override
 90  
   public MappingEntry<I, B> getCurrentEntry()
 91  
     throws IOException, InterruptedException {
 92  0
     return baseMappingReader.getCurrentEntry();
 93  
   }
 94  
 
 95  
 
 96  
   @Override
 97  
   public void close() throws IOException {
 98  0
     baseMappingReader.close();
 99  0
   }
 100  
 
 101  
   @Override
 102  
   public float getProgress() throws IOException, InterruptedException {
 103  0
     return baseMappingReader.getProgress();
 104  
   }
 105  
 }