Coverage Report - org.apache.giraph.utils.ByteStructVertexIdIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
ByteStructVertexIdIterator
0%
0/10
0%
0/6
1.75
 
 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.utils;
 20  
 
 21  
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 22  
 import org.apache.hadoop.io.WritableComparable;
 23  
 
 24  
 /**
 25  
  * Common implementation for VertexIdEdgeIterator, VertexIdMessageIterator
 26  
  * and VertexIdMessageBytesIterator.
 27  
  *
 28  
  * @param <I> Vertex id
 29  
  */
 30  
 public abstract class ByteStructVertexIdIterator<I extends WritableComparable>
 31  
   implements VertexIdIterator<I> {
 32  
   /** Reader of the serialized edges */
 33  
   protected final ExtendedDataInput extendedDataInput;
 34  
 
 35  
   /** Current vertex id */
 36  
   protected I vertexId;
 37  
 
 38  
   /**
 39  
    * Constructor.
 40  
    *
 41  
    * @param extendedDataOutput Extended data output
 42  
    * @param conf Configuration
 43  
    */
 44  
   public ByteStructVertexIdIterator(
 45  
     ExtendedDataOutput extendedDataOutput,
 46  0
     ImmutableClassesGiraphConfiguration<I, ?, ?> conf) {
 47  0
     if (extendedDataOutput != null && conf != null) {
 48  0
       extendedDataInput = conf.createExtendedDataInput(extendedDataOutput);
 49  
     } else {
 50  0
       throw new IllegalStateException("Cannot instantiate vertexIdIterator " +
 51  
         "with null arguments");
 52  
     }
 53  0
   }
 54  
 
 55  
   @Override
 56  
   public boolean hasNext() {
 57  0
     return !extendedDataInput.endOfInput();
 58  
   }
 59  
 
 60  
   @Override
 61  
   public I getCurrentVertexId() {
 62  0
     return vertexId;
 63  
   }
 64  
 
 65  
   @Override
 66  
   public I releaseCurrentVertexId() {
 67  0
     I releasedVertexId = vertexId;
 68  0
     vertexId = null;
 69  0
     return releasedVertexId;
 70  
   }
 71  
 }