Changes between Version 3 and Version 4 of NCHCCloudCourse100929_4_HBEX
- Timestamp:
- Sep 28, 2010, 6:18:12 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NCHCCloudCourse100929_4_HBEX
v3 v4 16 16 = !CreateTable.java = 17 17 {{{ 18 #! text18 #!java 19 19 package org.nchc.hbase; 20 20 … … 31 31 public static void createHBaseTable(String tablename, String family) 32 32 throws IOException { 33 // HTableDescriptor contains the name of an HTable, and its column34 // families35 33 // HTableDescriptor 用來描述table的屬性 36 34 HTableDescriptor htd = new HTableDescriptor(tablename); 37 // HColumnDescriptor HColumnDescriptor contains information about a 38 // column family such as the number of versions, compression settings, 39 // etc. 35 40 36 // HTableDescriptor 透過 add() 方法來加入Column family 41 42 37 htd.addFamily(new HColumnDescriptor(family)); 43 38 44 39 // HBaseConfiguration 能接收 hbase-site.xml 的設定值 45 40 HBaseConfiguration config = new HBaseConfiguration(); 41 46 42 // 檔案的操作則使用 HBaseAdmin 47 43 HBaseAdmin admin = new HBaseAdmin(config); 44 48 45 // 檢查 49 46 if (admin.tableExists(tablename)) { … … 51 48 } else { 52 49 System.out.println("create new table: " + tablename); 50 53 51 // 建立 54 52 admin.createTable(htd);