Entropy extends AbstractJob { private void calculateEntropy() throws IOException, ClassNotFoundException, InterruptedException { Job job = prepareJob(tempPath, getOutputPath(), SequenceFileInputFormat.class, CalculateEntropyMapper.class, NullWritable.class, DoubleWritable.class, CalculateEntropyReducer.class, NullWritable.class, DoubleWritable.class, SequenceFileOutputFormat.class); job.getConfiguration().set(NUMBER_ITEMS_PARAM, String.valueOf(numberItems)); job.setCombinerClass(DoubleSumReducer.class); job.waitForCompletion(true); }  static void main(String[] args); long getNumberItems(); @Override int run(String[] args);  }
@Test public void testLetters() throws Exception { String[] content = { "A", "A", "A", "A", "A", "B", "B", "C", "D", "E" }; calculateEntropy(content, 1.96096405, "key"); }
@Test public void testYN() throws Exception { String[] content = { "Yes", "No", "Yes", "No", "No", "Yes", "No", "Yes" }; calculateEntropy(content, 1.0, "value"); }