@@ -0,0 +1,1716 @@
+/*%0A * PURPOSE%0A * %09getting a source from input table, parsing into words,%0A *  making the permutations, and counting them by storing in another table.%0A */%0Apackage ztest.counter;%0A%0Aimport hbase.dao.CountersDAO;%0A%0Aimport java.io.IOException;%0A%0Aimport org.apache.hadoop.hbase.CellUtil;%0Aimport org.apache.hadoop.hbase.client.Put;%0Aimport org.apache.hadoop.hbase.client.Result;%0Aimport org.apache.hadoop.hbase.io.ImmutableBytesWritable;%0Aimport org.apache.hadoop.hbase.mapreduce.TableMapper;%0Aimport org.apache.hadoop.hbase.util.Bytes;%0Aimport org.apache.hadoop.io.Text;%0A%0Apublic class TestMapper extends TableMapper%3CText, Put%3E%7B%0A%0A%09protected void map(ImmutableBytesWritable rowkey, Result result, %0A%09%09%09Context context) %7B%0A%09%09// appending p:title and p:content in the result argumented. %0A%09%09// str = %22%3Ctitle%3E %3Ccontent%3E%22%0A%09%09String str = %22%22;%0A%09%09str += Bytes.toString(CellUtil.cloneValue(%0A%09%09%09%09result.getColumnLatestCell(%22p%22.getBytes(), %22title%22.getBytes())));%0A%09%09str += %22 %22;%0A%09%09str += Bytes.toString(CellUtil.cloneValue(%0A%09%09%09%09result.getColumnLatestCell(%22p%22.getBytes(), %22content%22.getBytes())));%0A%09%09%0A%09%09// to make the permutations%0A%09%09String%5B%5D alphas = str.split(%22 %22);%0A%09%09%0A%09%09/* debug printing%0A%09%09for (String s : alphas)%0A%09%09%09System.out.println(s);%0A%09%09*/%0A%09%09%0A%09%09// making the permutations, which increase count in the output table.%0A%09%09// thus, we can figure out how many times each permutation has been made.%0A%09%09for (String s1 : alphas) %7B%0A%09%09%09for (String s2 : alphas) %7B%0A%09%09%09%09if (s1.equals(s2)) continue;%0A%09%09%09%09%0A%09%09%09%09String outkey = s1 + %22:%22 + s2;%0A%09%09%09%09%0A%09%09%09%09try %7B%0A%09%09%09%09%09// delegate increasing count to CounterDAO class%0A%09%09%09%09%09CountersDAO cDao = new CountersDAO();%0A%09%09%09%09%09cDao.incCount(outkey, 1);%0A%09%09%09%09%7D catch (IOException e1) %7B%0A%09%09%09%09%09e1.printStackTrace();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create TestMapper.java