Changes between Initial Version and Version 1 of waue/2011/0425_Itri4SortTurnover


Ignore:
Timestamp:
Apr 25, 2011, 4:21:16 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2011/0425_Itri4SortTurnover

    v1 v1  
     1{{{
     2#!java
     3
     4package itri;
     5
     6
     7
     8// ITRI serial program number 4
     9
     10// 0. after Itri3CalculateMR
     11
     12// 1. run addIndexToTurnover() would add index table to itri.
     13
     14//    if you have indexed the table before, don't do it again.
     15
     16// 2. tune the filter_value in main() and run readSortedValGreater() would show report
     17
     18
     19
     20import java.io.IOException;
     21
     22
     23
     24import org.apache.hadoop.fs.Path;
     25
     26import org.apache.hadoop.hbase.HBaseConfiguration;
     27
     28import org.apache.hadoop.hbase.client.tableindexed.IndexSpecification;
     29
     30import org.apache.hadoop.hbase.client.tableindexed.IndexedTableAdmin;
     31
     32import org.apache.hadoop.hbase.util.Bytes;
     33
     34
     35
     36public class Itri4SortTurnover {
     37
     38
     39
     40        public void addIndexToTurnover(String OriTable, String IndexID,
     41
     42                        String OriColumn) throws IOException {
     43
     44                HBaseConfiguration conf = new HBaseConfiguration();
     45
     46                conf.addResource(new Path("/opt/hbase/conf/hbase-site.xml"));
     47
     48                IndexedTableAdmin admin = new IndexedTableAdmin(conf);
     49
     50                admin.tableExists(OriTable);
     51
     52                admin.addIndex(Bytes.toBytes(OriTable), new IndexSpecification(IndexID,
     53
     54                                Bytes.toBytes(OriColumn)));
     55
     56
     57
     58        }
     59
     60
     61
     62        public static void main(String[] argv) throws IOException {
     63
     64
     65
     66                Itri4SortTurnover tt = new Itri4SortTurnover();
     67
     68                tt.addIndexToTurnover("itri", "Sum", "Turnover:Sum");
     69
     70        }
     71
     72}
     73
     74}}}