HashPartitioner.java

package org.apache.hadoop.mapreduce.lib.partition;

import org.apache.hadoop.mapreduce.Partitioner;

public class HashPartitioner<K, V> extends Partitioner<K, V>{
	public int getPartition(K key, V value, int numReduceTasks){
		return (Key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
	}
}

ユーザー数のカウント処理

user_id_list = []

ARGF.each_line do |line|
line.chomp!

user_id = line.split(‘,’)[0]

unless user_id_list.include?(user_id)
user_id_list << user_id end end puts "UU数は#{user_id_list.size}です" [/code]