public static Map<String,List<Distributable>> nodeBlockMapping(List<Distributable> blockInfos,int noOfNodesInput,List<String> activeNodes){
  Map<String,List<Distributable>> nodeBlocksMap=new HashMap<String,List<Distributable>>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
  List<NodeBlockRelation> flattenedList=new ArrayList<NodeBlockRelation>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
  Set<Distributable> uniqueBlocks=new HashSet<Distributable>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
  Set<String> nodes=new HashSet<String>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
  createFlattenedListFromMap(blockInfos,flattenedList,uniqueBlocks,nodes);
  int noofNodes=(-1 == noOfNodesInput) ? nodes.size() : noOfNodesInput;
  if (null != activeNodes) {
    noofNodes=activeNodes.size();
  }
  int blocksPerNode=blockInfos.size() / noofNodes;
  blocksPerNode=blocksPerNode <= 0 ? 1 : blocksPerNode;
  Collections.sort(flattenedList);
  Map<String,List<Distributable>> nodeAndBlockMapping=new LinkedHashMap<String,List<Distributable>>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
  createNodeVsBlockMapping(flattenedList,nodeAndBlockMapping);
  createOutputMap(nodeBlocksMap,blocksPerNode,uniqueBlocks,nodeAndBlockMapping,activeNodes);
  assignLeftOverBlocks(nodeBlocksMap,uniqueBlocks,blocksPerNode,activeNodes);
  return nodeBlocksMap;
}

public static Map < String , List < Distributable > > nodeBlockMapping ( List < Distributable > blockInfos , int noOfNodesInput , List < String > activeNodes ) { Map < String , List < Distributable > > nodeBlocksMap = new HashMap < String , List < Distributable > > ( CarbonCommonConstants . DEFAULT_COLLECTION_SIZE ) ; List < NodeBlockRelation > flattenedList = new ArrayList < NodeBlockRelation > ( CarbonCommonConstants . DEFAULT_COLLECTION_SIZE ) ; Set < Distributable > uniqueBlocks = new HashSet < Distributable > ( CarbonCommonConstants . DEFAULT_COLLECTION_SIZE ) ; Set < String > nodes = new HashSet < String > ( CarbonCommonConstants . DEFAULT_COLLECTION_SIZE ) ; createFlattenedListFromMap ( blockInfos , flattenedList , uniqueBlocks , nodes ) ; int noofNodes = ( - 1 == noOfNodesInput ) ? nodes . size ( ) : noOfNodesInput ; if ( null != activeNodes ) { noofNodes = activeNodes . size ( ) ; } int blocksPerNode = blockInfos . size ( ) / noofNodes ; blocksPerNode = blocksPerNode <= 0 ? 1 : blocksPerNode ; Collections . sort ( flattenedList ) ; Map < String , List < Distributable > > nodeAndBlockMapping = new LinkedHashMap < String , List < Distributable > > ( CarbonCommonConstants . DEFAULT_COLLECTION_SIZE ) ; createNodeVsBlockMapping ( flattenedList , nodeAndBlockMapping ) ; createOutputMap ( nodeBlocksMap , blocksPerNode , uniqueBlocks , nodeAndBlockMapping , activeNodes ) ; assignLeftOverBlocks ( nodeBlocksMap , uniqueBlocks , blocksPerNode , activeNodes ) ; return nodeBlocksMap ; }
this method will divide the blocks among the nodes as per the data locality
