Coverage Report - org.apache.giraph.utils.AbstractVertexIdData
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractVertexIdData
0%
0/29
0%
0/2
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.utils;
 20  
 
 21  
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 22  
 import org.apache.hadoop.io.WritableComparable;
 23  
 
 24  
 import java.io.DataInput;
 25  
 import java.io.DataOutput;
 26  
 import java.io.IOException;
 27  
 
 28  
 import static org.apache.giraph.utils.ByteUtils.SIZE_OF_BYTE;
 29  
 import static org.apache.giraph.utils.ByteUtils.SIZE_OF_INT;
 30  
 
 31  
 /**
 32  
  * Partial implementation of vertexIdData
 33  
  *
 34  
  * @param <I> vertexId type parameter
 35  
  * @param <T> vertexData type parameter
 36  
  */
 37  0
 @SuppressWarnings("unchecked")
 38  0
 public abstract class AbstractVertexIdData<I extends WritableComparable, T>
 39  
   implements VertexIdData<I, T> {
 40  
   /** Extended data output */
 41  
   protected ExtendedDataOutput extendedDataOutput;
 42  
   /** Configuration */
 43  
   private ImmutableClassesGiraphConfiguration<I, ?, ?> configuration;
 44  
 
 45  
   @Override
 46  
   public void initialize() {
 47  0
     extendedDataOutput = getConf().createExtendedDataOutput();
 48  0
   }
 49  
 
 50  
   @Override
 51  
   public void initialize(int expectedSize) {
 52  0
     extendedDataOutput = getConf().createExtendedDataOutput(expectedSize);
 53  0
   }
 54  
 
 55  
   @Override
 56  
   public void add(I vertexId, T data) {
 57  
     try {
 58  0
       vertexId.write(extendedDataOutput);
 59  0
       writeData(extendedDataOutput, data);
 60  0
     } catch (IOException e) {
 61  0
       throw new IllegalStateException("add: IOException", e);
 62  0
     }
 63  0
   }
 64  
 
 65  
   @Override
 66  
   public void add(byte[] serializedId, int idPos, T data) {
 67  
     try {
 68  0
       extendedDataOutput.write(serializedId, 0, idPos);
 69  0
       writeData(extendedDataOutput, data);
 70  0
     } catch (IOException e) {
 71  0
       throw new IllegalStateException("add: IOException", e);
 72  0
     }
 73  0
   }
 74  
 
 75  
   @Override
 76  
   public int getSize() {
 77  0
     return extendedDataOutput.getPos();
 78  
   }
 79  
 
 80  
 
 81  
   @Override
 82  
   public int getSerializedSize() {
 83  0
     return SIZE_OF_BYTE + SIZE_OF_INT + getSize();
 84  
   }
 85  
 
 86  
 
 87  
   @Override
 88  
   public boolean isEmpty() {
 89  0
     return extendedDataOutput.getPos() == 0;
 90  
   }
 91  
 
 92  
 
 93  
   @Override
 94  
   public void clear() {
 95  0
     extendedDataOutput.reset();
 96  0
   }
 97  
 
 98  
   @Override
 99  
   public void setConf(ImmutableClassesGiraphConfiguration configuration) {
 100  0
     this.configuration = configuration;
 101  0
   }
 102  
 
 103  
   @Override
 104  
   public ImmutableClassesGiraphConfiguration<I, ?, ?> getConf() {
 105  0
     return configuration;
 106  
   }
 107  
 
 108  
   @Override
 109  
   public ByteStructVertexIdDataIterator<I, T> getVertexIdDataIterator() {
 110  0
     return new ByteStructVertexIdDataIterator<>(this);
 111  
   }
 112  
 
 113  
   @Override
 114  
   public void write(DataOutput output) throws IOException {
 115  0
     throw new UnsupportedOperationException("not supported");
 116  
   }
 117  
 
 118  
   @Override
 119  
   public void readFields(DataInput dataInput) throws IOException {
 120  0
     throw new UnsupportedOperationException("not supported");
 121  
   }
 122  
 }