Coverage Report - org.apache.giraph.io.formats.TextDoubleDoubleAdjacencyListVertexInputFormat
 
Classes in this File Line Coverage Branch Coverage Complexity
TextDoubleDoubleAdjacencyListVertexInputFormat
0%
0/2
N/A
1
TextDoubleDoubleAdjacencyListVertexInputFormat$TextDoubleDoubleAdjacencyListVertexReader
0%
0/8
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  
 package org.apache.giraph.io.formats;
 19  
 
 20  
 import org.apache.giraph.edge.Edge;
 21  
 import org.apache.giraph.edge.EdgeFactory;
 22  
 import org.apache.hadoop.io.DoubleWritable;
 23  
 import org.apache.hadoop.io.Text;
 24  
 import org.apache.hadoop.mapreduce.InputSplit;
 25  
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 26  
 
 27  
 /**
 28  
  * Class to read graphs stored as adjacency lists with ids represented by
 29  
  * Strings and values as doubles.  This is a good inputformat for reading
 30  
  * graphs where the id types do not matter and can be stashed in a String.
 31  
  */
 32  0
 public class TextDoubleDoubleAdjacencyListVertexInputFormat
 33  
     extends AdjacencyListTextVertexInputFormat<Text, DoubleWritable,
 34  
             DoubleWritable>  {
 35  
 
 36  
   @Override
 37  
   public AdjacencyListTextVertexReader createVertexReader(InputSplit split,
 38  
       TaskAttemptContext context) {
 39  0
     return new TextDoubleDoubleAdjacencyListVertexReader(null);
 40  
   }
 41  
 
 42  
   /**
 43  
    * Vertex reader used with
 44  
    * {@link TextDoubleDoubleAdjacencyListVertexInputFormat}
 45  
    */
 46  0
   protected class TextDoubleDoubleAdjacencyListVertexReader extends
 47  
       AdjacencyListTextVertexReader {
 48  
 
 49  
     /**
 50  
      * Constructor with
 51  
      * {@link AdjacencyListTextVertexInputFormat.LineSanitizer}.
 52  
      *
 53  
      * @param lineSanitizer the sanitizer to use for reading
 54  
      */
 55  
     public TextDoubleDoubleAdjacencyListVertexReader(LineSanitizer
 56  0
         lineSanitizer) {
 57  0
       super(lineSanitizer);
 58  0
     }
 59  
 
 60  
     @Override
 61  
     public Text decodeId(String s) {
 62  0
       return new Text(s);
 63  
     }
 64  
 
 65  
     @Override
 66  
     public DoubleWritable decodeValue(String s) {
 67  0
       return new DoubleWritable(Double.parseDouble(s));
 68  
     }
 69  
 
 70  
     @Override
 71  
     public Edge<Text, DoubleWritable> decodeEdge(String s1, String s2) {
 72  0
       return EdgeFactory.create(new Text(s1),
 73  0
           new DoubleWritable(Double.parseDouble(s2)));
 74  
     }
 75  
   }
 76  
 
 77  
 }