Changeset 31 for sample/hadoop-0.16/test.java
- Timestamp:
- Jul 17, 2008, 3:35:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/hadoop-0.16/test.java
r25 r31 8 8 import java.io.RandomAccessFile; 9 9 import java.util.StringTokenizer; 10 10 11 import org.apache.hadoop.fs.FileStatus; 11 12 import org.apache.hadoop.fs.FileSystem; 12 13 import 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;18 14 import org.apache.hadoop.mapred.JobConf; 19 15 … … 27 23 System.out.println(test.sna); 28 24 } 29 30 25 } 31 26 32 27 public class test { 33 28 int na; 34 35 29 static int sna; 36 37 30 static String str; 38 39 31 public test() { 40 41 32 } 42 33 … … 49 40 sna = b; 50 41 str = st; 51 52 42 } 53 43 … … 108 98 } while (true); 109 99 fw.close(); 110 111 100 return first_line; 112 101 } … … 114 103 boolean deleteFile(String str) throws IOException { 115 104 File ttt = new File(str); 116 117 105 if (ttt.exists()) { 118 106 if (!ttt.delete()) { … … 122 110 System.out.println("file not exit!"); 123 111 } 124 125 112 return true; 126 113 } … … 143 130 // "/home/waue/out.tmp.txt")); 144 131 // 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 145 146 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(); 180 154 } 181 155 } 156 class Fu <T>{ 157 T go; 158 void setFu(T go){ 159 this.go = go; 160 } 161 T getFu(){ 162 return go; 163 } 164 } 165 166 class 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 } 174 class 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 } 183 class 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.