Ignore:
Timestamp:
Jul 2, 2008, 3:10:09 PM (16 years ago)
Author:
waue
Message:

upgrade 0.16 to 0.17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/WordCountIntoHBase.java

    r8 r18  
    33 * Editor: Waue Chen
    44 * From :  NCHC. Taiwn
    5  * Last Update Date: 06/10/2008
     5 * Last Update Date: 07/02/2008
     6 * Upgrade to 0.17
    67 */
    78
     
    4344
    4445  /* setup parameters */
    45   // $Input_Path. Please make sure the path is correct and contains input files
     46  // $Input_Path. Please make sure the path is correct and contains input
     47  // files
    4648  static final String Input_Path = "/user/waue/simple";
     49
    4750  // Hbase table name, the program will create it
    4851  static final String Table_Name = "word_count5";
     52
    4953  // column name, the program will create it
    50   static final String colstr = "word:text" ;
    51  
     54  static final String colstr = "word:text";
     55
    5256  // constructor
    5357  private WordCountIntoHBase() {
     
    5761    // set (column_family:column_qualify)
    5862    private static final Text col = new Text(WordCountIntoHBase.colstr);
     63
    5964    // this map holds the columns per row
    6065    private MapWritable map = new MapWritable();
     66
    6167    public void reduce(LongWritable key, Iterator<Text> values,
    6268        OutputCollector<Text, MapWritable> output, Reporter reporter)
    6369        throws IOException {
    6470      // contents must be ImmutableBytesWritable
    65       ImmutableBytesWritable bytes =
    66         new ImmutableBytesWritable(values.next().getBytes());     
     71      ImmutableBytesWritable bytes = new ImmutableBytesWritable(values
     72          .next().getBytes());
    6773      map.clear();
    68       // write data 
     74      // write data
    6975      map.put(col, bytes);
    7076      // add the row with the key as the row id
     
    7682   * Runs the demo.
    7783   */
    78   public static void main(String[] args) throws IOException { 
     84  public static void main(String[] args) throws IOException {
    7985    // parse colstr to split column family and column qualify
    8086    String tmp[] = colstr.split(":");
    81     String Column_Family = tmp[0]+":";
    82     String CF[] = {Column_Family};
    83     // check whether create table or not , we don't admit \ 
     87    String Column_Family = tmp[0] + ":";
     88    String CF[] = { Column_Family };
     89    // check whether create table or not , we don't admit \
    8490    // the same name but different structure
    85     BuildHTable build_table = new BuildHTable(Table_Name,CF);
     91    BuildHTable build_table = new BuildHTable(Table_Name, CF);
    8692    if (!build_table.checkTableExist(Table_Name)) {
    8793      if (!build_table.createTable()) {
    8894        System.out.println("create table error !");
    8995      }
    90     }else{
    91       System.out.println("Table \"" + Table_Name +"\" has already existed !");
     96    } else {
     97      System.out.println("Table \"" + Table_Name
     98          + "\" has already existed !");
    9299    }
    93100    int mapTasks = 1;
     
    100107    conf.setNumMapTasks(mapTasks);
    101108    conf.setNumReduceTasks(reduceTasks);
    102     conf.setInputPath(new Path(Input_Path));
     109    // 0.16
     110    // conf.setInputPath(new Path(Input_Path));
     111    Convert.setInputPath(conf, new Path(Input_Path));
    103112    conf.setMapperClass(IdentityMapper.class);
    104113    conf.setCombinerClass(IdentityReducer.class);
Note: See TracChangeset for help on using the changeset viewer.