Changes between Version 19 and Version 20 of hbase_table_design


Ignore:
Timestamp:
09/19/2012 12:20:13 PM (14 years ago)
Author:
liaojiaohe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • hbase_table_design

    v19 v20  
    1717 
    1818  
    19 ==      2rowkey[[BR]] == 
     19==      2.rowkey[[BR]] == 
    2020 
    2121 
     
    2727 
    2828 
    29 ==       3columnfamily[[BR]] == 
     29==       3.columnfamily[[BR]] == 
    3030 
    3131 
     
    3333 
    3434 
    35 ==       4column[[BR]] == 
     35==       4.column[[BR]] == 
    3636 
    3737 
     
    4040     (2) column的数目不要超过百万,不然会出现OOM。如果column过多,可以考虑将column设计到rowkey的方法解决。例如原来的rowkey是uid1,,column是uid2,uid3...。重新设计之后rowkey为<uid1>~<uid2>,<uid1>~<uid3>...,采用scan(startkey,endkey)的扫描方法来读数据[[BR]] 
    4141 
     42 
     43 
     44==     5.counter  == 
     45使用counter自增可以保证操作的原子性 
     46 
     47 
     48{{{ 
     49import java.io.IOException; 
     50  
     51import org.apache.hadoop.conf.Configuration; 
     52import org.apache.hadoop.hbase.HBaseConfiguration; 
     53import org.apache.hadoop.hbase.client.HTable; 
     54import org.apache.hadoop.hbase.util.Bytes; 
     55  
     56public class test_counter { 
     57  
     58    public static void main(String[] args) throws IOException { 
     59  
     60        Configuration conf = null; 
     61        conf = HBaseConfiguration.create(); 
     62        conf.set("hbase.zookeeper.quorum", "192.168.11.64"); 
     63  
     64        HTable table = new HTable(conf, Bytes.toBytes("test_table")); 
     65        long c = table.incrementColumnValue(Bytes.toBytes("100"), Bytes.toBytes("cf1"), 
     66                Bytes.toBytes("column1"), 4); 
     67        table.close(); 
     68  
     69    } 
     70  
     71} 
     72}}} 
    4273 
    4374