You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Harun Raşit ER <ha...@gmail.com> on 2012/03/25 17:12:35 UTC

custom partitioner

My custom parititoner is:
public class PopulationPartitioner extends Partitioner <IntWritable,
Chromosome> implements Configurable
{	
	@Override
	public int getPartition(IntWritable key, Chromosome value, int
numOfPartitions) {
		
		int partition = key.get();
		if (partition < 0 || partition >= numOfPartitions)
		{
			partition = numOfPartitions-1;
		}
		System.out.println("partition "+partition );
		return partition;
	}

	@Override
	public Configuration getConf() {
		// TODO Auto-generated method stub
		return conf;
	}

	@Override
	public void setConf(Configuration arg0) {
		// TODO Auto-generated method stub
		conf = arg0;
		
	}
	
	private Configuration conf;
}

And my mapred configuration file is :

<configuration>
 <property>
  <name>mapred.job.tracker</name>
  <value>localhost:9001</value>
 </property>
 <property>
  <name>mapred.tasktracker.reduce.tasks.maximum</name>
  <value>4</value>
 </property>
</configuration>

Thanks again.

----------------------------------------------------------------
This shouldn't be the case at all. Can you share your Partitioner code
and the job.xml of the job that showed this behavior?

In any case: How do you "set the numberOfReducer to 4"?

2012/3/23 Harun Raşit ER <ha...@gmail.com>:
> I wrote a custom partitioner. But when I work as standalone or
> pseudo-distributed mode, the number of partitions is always 1. I set the
> numberOfReducer to 4, but the numOfPartitions parameter of custom
> partitioner is still 1 and all my four mappers' results are going to 1
> reducer. The other reducers yield empty files.
>
> How can i set the number of partitions in standalone or pseudo-distributed
> mode?
>
> thanks for your helps.



-- 
Harsh J