Changes between Version 3 and Version 4 of NCHCCloudCourse100929_4_HBEX


Ignore:
Timestamp:
Sep 28, 2010, 6:18:12 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NCHCCloudCourse100929_4_HBEX

    v3 v4  
    1616= !CreateTable.java =
    1717{{{
    18 #!text
     18#!java
    1919package org.nchc.hbase;
    2020
     
    3131        public static void createHBaseTable(String tablename, String family)
    3232                        throws IOException {
    33                 // HTableDescriptor contains the name of an HTable, and its column
    34                 // families
    3533                // HTableDescriptor 用來描述table的屬性
    3634                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
    4036                // HTableDescriptor 透過 add() 方法來加入Column family
    41 
    4237                htd.addFamily(new HColumnDescriptor(family));
    4338
    4439                // HBaseConfiguration 能接收 hbase-site.xml 的設定值
    4540                HBaseConfiguration config = new HBaseConfiguration();
     41
    4642                // 檔案的操作則使用 HBaseAdmin
    4743                HBaseAdmin admin = new HBaseAdmin(config);
     44
    4845                // 檢查
    4946                if (admin.tableExists(tablename)) {
     
    5148                } else {
    5249                        System.out.println("create new table: " + tablename);
     50
    5351                        // 建立
    5452                        admin.createTable(htd);