Ignore:
Timestamp:
Jul 17, 2008, 3:35:18 PM (16 years ago)
Author:
waue
Message:

update some new ..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/hadoop-0.16/test.java

    r25 r31  
    88import java.io.RandomAccessFile;
    99import java.util.StringTokenizer;
     10
    1011import org.apache.hadoop.fs.FileStatus;
    1112import org.apache.hadoop.fs.FileSystem;
    1213import org.apache.hadoop.fs.Path;
    13 import org.apache.hadoop.hbase.HBaseAdmin;
    14 import org.apache.hadoop.hbase.HBaseConfiguration;
    15 import org.apache.hadoop.hbase.HColumnDescriptor;
    16 import org.apache.hadoop.hbase.HTableDescriptor;
    17 import org.apache.hadoop.io.Text;
    1814import org.apache.hadoop.mapred.JobConf;
    1915
     
    2723    System.out.println(test.sna);
    2824  }
    29 
    3025}
    3126
    3227public class test {
    3328  int na;
    34 
    3529  static int sna;
    36 
    3730  static String str;
    38 
    3931  public test() {
    40 
    4132  }
    4233
     
    4940    sna = b;
    5041    str = st;
    51 
    5242  }
    5343
     
    10898    } while (true);
    10999    fw.close();
    110 
    111100    return first_line;
    112101  }
     
    114103  boolean deleteFile(String str) throws IOException {
    115104    File ttt = new File(str);
    116 
    117105    if (ttt.exists()) {
    118106      if (!ttt.delete()) {
     
    122110      System.out.println("file not exit!");
    123111    }
    124 
    125112    return true;
    126113  }
     
    143130    // "/home/waue/out.tmp.txt"));
    144131    // ttt();
     132   
     133   
     134    animal a = new animal();
     135    bird b = new bird();
     136    dog d = new dog(b);
     137    animal aaa = new bird();
     138//    dog ddd = new animal();  -> error
     139   
     140    animal aa = (animal) b;
     141    System.out.println(aa.hand);
     142    System.out.println(aa.mind);   
     143//    bird bb = (bird) a; -> error
     144//    d.setbird(aa); -> error
     145//    System.out.println(aa.feather); -> error
    145146
    146 
    147     // setup Table name
    148     String table_name = "test_create_table2";
    149     Text text_table_name = new Text(table_name);
    150     // setup Column Family
    151     String[] Column_Family = { "http:", "url:", "referrer:" };
    152     HBaseConfiguration conf = new HBaseConfiguration();
    153 
    154     HBaseAdmin admin = new HBaseAdmin(conf);
    155     boolean b = admin.tableExists(text_table_name);
    156     System.out.println(b);
    157 
    158     if (!admin.tableExists(text_table_name)) {
    159 
    160       System.out.println("HTable : " + table_name
    161           + "  creating ... please wait");
    162       HTableDescriptor tableDesc = new HTableDescriptor(table_name);
    163       for (int i = 0; i < Column_Family.length; i++) {
    164         String st = Column_Family[i];
    165         // check name format "string:"
    166         if (!st.endsWith(":")) {
    167           Column_Family[i] = st + ":";
    168           System.out.println("normize :" + st + "->"
    169               + Column_Family[i]);
    170         }
    171         // add column family
    172         tableDesc.addFamily(new HColumnDescriptor(Column_Family[i]));
    173       }
    174       admin.createTable(tableDesc);
    175     } else {
    176       System.out.println("table exist!");
    177     }
    178 
    179 
     147    // Fu <T>
     148    Fu<? extends String> ak;
     149    ak = new Fu<String>();
     150    ak.getFu();
     151    Fu<?> in = ak;
     152//    in.setFu("ss"); -> error
     153    in.getFu();
    180154  }
    181155}
     156class Fu <T>{
     157  T go;
     158  void setFu(T go){
     159    this.go = go;
     160  }
     161  T getFu(){
     162    return go;
     163  }
     164}
     165
     166class animal{
     167  String head = "head";
     168  String feet = "feet";
     169  String body = "body";
     170  String hand = "head";
     171  String mind = "mind";
     172  int id = 1234567;
     173}
     174class bird extends animal{
     175  String feather = "feather";
     176  bird(){
     177    hand = "wing";
     178    id = 1234568;
     179    System.out.println(head + hand + body + feet + "id="+id);
     180    System.out.println("super = " + super.hand +"this = " + this.hand);
     181  }
     182}
     183class dog extends animal{
     184  dog(animal a){
     185    System.out.println(a.head + hand + body + feet + "id="+id);
     186  }
     187  void setbird(bird b){
     188    System.out.println(b.head + hand + body + feet + "id="+id);
     189  }
     190}
Note: See TracChangeset for help on using the changeset viewer.