Coverage Report - org.apache.giraph.worker.LocalData
 
Classes in this File Line Coverage Branch Coverage Complexity
LocalData
0%
0/18
0%
0/10
2
 
 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.worker;
 20  
 
 21  
 import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable;
 22  
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
 23  
 import org.apache.giraph.mapping.MappingStore;
 24  
 import org.apache.giraph.mapping.MappingStoreOps;
 25  
 import org.apache.hadoop.io.Writable;
 26  
 import org.apache.hadoop.io.WritableComparable;
 27  
 import org.apache.log4j.Logger;
 28  
 
 29  
 /**
 30  
  * Stores LocalData for each worker
 31  
  *
 32  
  * @param <I> vertexId type
 33  
  * @param <V> vertex value type
 34  
  * @param <E> edge value type
 35  
  * @param <B> mappingTarget type
 36  
  */
 37  
 @SuppressWarnings("unchecked")
 38  
 public class LocalData<I extends WritableComparable, V extends Writable,
 39  
   E extends Writable, B extends Writable>
 40  
   extends DefaultImmutableClassesGiraphConfigurable<I, V, E> {
 41  
   /** Logger Instance */
 42  0
   private static final Logger LOG = Logger.getLogger(LocalData.class);
 43  
   /** MappingStore from vertexId - target */
 44  
   private MappingStore<I, B> mappingStore;
 45  
   /** Do operations using mapping store */
 46  
   private MappingStoreOps<I, B> mappingStoreOps;
 47  
   /**
 48  
    * Constructor
 49  
    *
 50  
    * Set configuration, create &amp; initialize mapping store
 51  
    * @param conf giraph configuration
 52  
    */
 53  0
   public LocalData(ImmutableClassesGiraphConfiguration<I, V, E> conf) {
 54  
     // set configuration
 55  0
     setConf(conf);
 56  
     // check if user set the mapping store => create & initialize it
 57  0
     mappingStore = (MappingStore<I, B>) getConf().createMappingStore();
 58  0
     if (mappingStore != null) {
 59  0
       mappingStore.initialize();
 60  
     }
 61  0
     mappingStoreOps = (MappingStoreOps<I, B>) getConf().createMappingStoreOps();
 62  0
     if (mappingStoreOps != null) {
 63  0
       mappingStoreOps.initialize(mappingStore);
 64  
     }
 65  0
   }
 66  
 
 67  
   public MappingStore<I, B> getMappingStore() {
 68  0
     return mappingStore;
 69  
   }
 70  
 
 71  
   public MappingStoreOps<I, B> getMappingStoreOps() {
 72  0
     return mappingStoreOps;
 73  
   }
 74  
 
 75  
   /**
 76  
    * Remove mapping store from localData
 77  
    * if mapping data is already embedded into vertexIds
 78  
    */
 79  
   public void removeMappingStoreIfPossible() {
 80  0
     if (mappingStoreOps != null && mappingStoreOps.hasEmbedding()) {
 81  0
       mappingStore = null;
 82  
     }
 83  0
   }
 84  
 
 85  
   /**
 86  
    * Prints Stats of individual data it stores
 87  
    */
 88  
   public void printStats() {
 89  0
     if (LOG.isInfoEnabled()) {
 90  0
       LOG.info("MappingStore has : " + mappingStore.getStats() + " entries");
 91  
     }
 92  0
   }
 93  
 }