List of usage examples for org.apache.hadoop.io MapWritable values
@Override
public Collection<Writable> values()
From source file:full_MapReduce.FindBestAttributeMapper.java
License:Open Source License
private double global_entropy(MapWritable data, int tot_tuple) { double res = 0.0; Map<Text, Integer> count_per_class = new HashMap<Text, Integer>(); for (Writable tmp_cur_map : data.values()) { MapWritable cur_map = (MapWritable) tmp_cur_map; for (Writable cur_key : cur_map.keySet()) { Text cur_key_text = (Text) cur_key; if (!count_per_class.containsKey(cur_key_text)) { count_per_class.put(new Text(cur_key_text), 0); }//from w w w . j ava2 s . c o m count_per_class.put(cur_key_text, ((IntWritable) cur_map.get(cur_key)).get() + count_per_class.get(cur_key_text)); } } double p; for (Integer i : count_per_class.values()) { p = (i * 1.0) / tot_tuple; res -= p * Math.log(p) / Math.log(2); } return res; }