package itri;
// ITRI serial program number 4
// 0. after Itri3CalculateMR
// 1. run addIndexToTurnover() would add index table to itri.
// if you have indexed the table before, don't do it again.
// 2. tune the filter_value in main() and run readSortedValGreater() would show report
import java.io.IOException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.tableindexed.IndexSpecification;
import org.apache.hadoop.hbase.client.tableindexed.IndexedTableAdmin;
import org.apache.hadoop.hbase.util.Bytes;
public class Itri4SortTurnover {
public void addIndexToTurnover(String OriTable, String IndexID,
String OriColumn) throws IOException {
HBaseConfiguration conf = new HBaseConfiguration();
conf.addResource(new Path("/opt/hbase/conf/hbase-site.xml"));
IndexedTableAdmin admin = new IndexedTableAdmin(conf);
admin.tableExists(OriTable);
admin.addIndex(Bytes.toBytes(OriTable), new IndexSpecification(IndexID,
Bytes.toBytes(OriColumn)));
}
public static void main(String[] argv) throws IOException {
Itri4SortTurnover tt = new Itri4SortTurnover();
tt.addIndexToTurnover("itri", "Sum", "Turnover:Sum");
}
}