Coverage Report - org.apache.giraph.mapping.translate.LongByteTranslateEdge
 
Classes in this File Line Coverage Branch Coverage Complexity
LongByteTranslateEdge
0%
0/10
N/A
1.125
LongByteTranslateEdge$DoubleEdgeValue
0%
0/2
N/A
1.125
LongByteTranslateEdge$FloatEdgeValue
0%
0/2
N/A
1.125
LongByteTranslateEdge$IntEdgeValue
0%
0/2
N/A
1.125
LongByteTranslateEdge$LongEdgeValue
0%
0/2
N/A
1.125
LongByteTranslateEdge$NoEdgeValue
0%
0/2
N/A
1.125
 
 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.mapping.translate;
 20  
 
 21  
 import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable;
 22  
 import org.apache.giraph.worker.BspServiceWorker;
 23  
 import org.apache.giraph.worker.LocalData;
 24  
 import org.apache.hadoop.io.ByteWritable;
 25  
 import org.apache.hadoop.io.DoubleWritable;
 26  
 import org.apache.hadoop.io.FloatWritable;
 27  
 import org.apache.hadoop.io.IntWritable;
 28  
 import org.apache.hadoop.io.LongWritable;
 29  
 import org.apache.hadoop.io.NullWritable;
 30  
 import org.apache.hadoop.io.Writable;
 31  
 
 32  
 /**
 33  
  * Basic implementation of Translate Edge
 34  
  * where I = LongWritable & B = ByteWritable
 35  
  *
 36  
  * @param <E> edge value type
 37  
  */
 38  0
 @SuppressWarnings("unchecked")
 39  0
 public class LongByteTranslateEdge<E extends Writable>
 40  
   extends DefaultImmutableClassesGiraphConfigurable
 41  
   implements TranslateEdge<LongWritable, E> {
 42  
 
 43  
   /** Local data used for targetId translation of edge */
 44  
   private LocalData<LongWritable,
 45  
     ? extends Writable, E, ByteWritable> localData;
 46  
 
 47  
   @Override
 48  
   public void initialize(BspServiceWorker<LongWritable,
 49  
     ? extends Writable, E> service) {
 50  0
     localData = (LocalData<LongWritable, ? extends Writable, E, ByteWritable>)
 51  0
       service.getLocalData();
 52  0
   }
 53  
 
 54  
   @Override
 55  
   public LongWritable translateId(LongWritable targetId) {
 56  0
     LongWritable translatedId = new LongWritable();
 57  0
     translatedId.set(targetId.get());
 58  0
     localData.getMappingStoreOps().embedTargetInfo(translatedId);
 59  0
     return translatedId;
 60  
   }
 61  
 
 62  
   @Override
 63  
   public E cloneValue(E edgeValue) {
 64  
     // If vertex input does not have create edges,
 65  
     // then you can use LongByteTranslateEdge directly
 66  0
     throw new UnsupportedOperationException();
 67  
   }
 68  
 
 69  
   /**
 70  
    * Correct implementation of cloneValue when edgevalue = nullwritable
 71  
    */
 72  0
   public static class NoEdgeValue
 73  
     extends LongByteTranslateEdge<NullWritable> {
 74  
     @Override
 75  
     public NullWritable cloneValue(NullWritable edgeValue) {
 76  0
       return NullWritable.get();
 77  
     }
 78  
   }
 79  
 
 80  
   /**
 81  
    * Correct implementation of cloneValue when edgevalue = intwritable
 82  
    */
 83  0
   public static class IntEdgeValue
 84  
       extends LongByteTranslateEdge<IntWritable> {
 85  
     @Override
 86  
     public IntWritable cloneValue(IntWritable edgeValue) {
 87  0
       return new IntWritable(edgeValue.get());
 88  
     }
 89  
   }
 90  
 
 91  
   /**
 92  
    * Correct implementation of cloneValue when edgevalue = longwritable
 93  
    */
 94  0
   public static class LongEdgeValue
 95  
     extends LongByteTranslateEdge<LongWritable> {
 96  
     @Override
 97  
     public LongWritable cloneValue(LongWritable edgeValue) {
 98  0
       return new LongWritable(edgeValue.get());
 99  
     }
 100  
   }
 101  
 
 102  
   /**
 103  
    * Correct implementation of cloneValue when edgevalue = floatwritable
 104  
    */
 105  0
   public static class FloatEdgeValue
 106  
     extends LongByteTranslateEdge<FloatWritable> {
 107  
     @Override
 108  
     public FloatWritable cloneValue(FloatWritable edgeValue) {
 109  0
       return new FloatWritable(edgeValue.get());
 110  
     }
 111  
   }
 112  
 
 113  
   /**
 114  
    * Correct implementation of cloneValue when edgevalue = doublewritable
 115  
    */
 116  0
   public static class DoubleEdgeValue
 117  
     extends LongByteTranslateEdge<DoubleWritable> {
 118  
     @Override
 119  
     public DoubleWritable cloneValue(DoubleWritable edgeValue) {
 120  0
       return new DoubleWritable(edgeValue.get());
 121  
     }
 122  
   }
 123  
 }