Coverage Report - org.apache.giraph.partition.LongMappingStorePartitionerFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
LongMappingStorePartitionerFactory
0%
0/11
0%
0/2
1.333
 
 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.partition;
 20  
 
 21  
 import org.apache.giraph.worker.LocalData;
 22  
 import org.apache.hadoop.io.LongWritable;
 23  
 import org.apache.hadoop.io.Writable;
 24  
 import org.apache.log4j.Logger;
 25  
 
 26  
 /**
 27  
  * Factory for long-byte mapping based partitioners.
 28  
  *
 29  
  * @param <V> vertexValue type
 30  
  * @param <E> edgeValue type
 31  
  */
 32  0
 @SuppressWarnings("unchecked")
 33  0
 public class LongMappingStorePartitionerFactory<V extends Writable,
 34  
     E extends Writable> extends GraphPartitionerFactory<LongWritable, V, E> {
 35  
   /** Logger Instance */
 36  0
   private static final Logger LOG = Logger.getLogger(
 37  
       LongMappingStorePartitionerFactory.class);
 38  
   /** Local Data that supplies the mapping store */
 39  0
   protected LocalData<LongWritable, V, E, ? extends Writable> localData = null;
 40  
 
 41  
   @Override
 42  
   public void initialize(LocalData<LongWritable, V, E,
 43  
     ? extends Writable> localData) {
 44  0
     this.localData = localData;
 45  0
     LOG.info("Initializing LongMappingStorePartitionerFactory with localData");
 46  0
   }
 47  
 
 48  
   @Override
 49  
   public int getPartition(LongWritable id, int partitionCount,
 50  
     int workerCount) {
 51  0
     return localData.getMappingStoreOps().getPartition(id,
 52  
         partitionCount, workerCount);
 53  
   }
 54  
 
 55  
   @Override
 56  
   public int getWorker(int partition, int partitionCount, int workerCount) {
 57  0
     int numRows = partitionCount / workerCount;
 58  0
     numRows = (numRows * workerCount == partitionCount) ? numRows : numRows + 1;
 59  0
     return partition / numRows;
 60  
   }
 61  
 }