Changes between Version 8 and Version 9 of waue/2009/0626


Ignore:
Timestamp:
Jul 24, 2009, 11:31:04 AM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2009/0626

    v8 v9  
    116116 * Scanner連接到HBase後,怎麼把內容萃取出來呢? 用到 RowResult承接 Scanner.next()方法,然而一個row裡面,會有
    117117 許多colomn_family,每個colomn_family又會有自己的column_quolify,形成colomn_family:column_quolify的二維結構。
     118 * 提供兩個方法 [法一] [法二],方法都一樣,只是步驟有點不同
    118119   * getRow() : 把row的名稱秀出來
    119120   * get(colomn_family:column_quolify) : 把該cell的值秀出來
    120121 * for (!RowResult result : scanner)  可以看成是
    121122 for (int i=0; i< scanner.length; i++){ !RowResult result[i] = scanner[i];
     123   * 但是 scanner沒有 hasnext 或 length的方法,因此用for還滿簡潔的
    122124 
    123125 
     
    128130RowResult rowResult = scanner.next();
    129131
     132// 法一
    130133while (rowResult != null) {
    131134
     
    138141}
    139142
     143//法二
    140144for (RowResult result : scanner) {
    141145        System.out.println("Found row: "
    142                         + Bytes.toString(rowResult.getRow())
     146                        + Bytes.toString(result.getRow())
    143147                        + " with value: "
    144                         + rowResult.get(Bytes
     148                        + result.get(Bytes
    145149                                        .toBytes(colomn_family+column_quolify)));
    146150}
     
    227231                for (RowResult result : scanner) {
    228232                        System.out.println("Found row: "
    229                                         + Bytes.toString(rowResult.getRow())
     233                                        + Bytes.toString(result.getRow())
    230234                                        + " with value: "
    231                                         + rowResult.get(Bytes
     235                                        + result.get(Bytes
    232236                                                        .toBytes(colomn_family+column_quolify)));
    233237                }