hbase-java-api001

來源:互聯網
上載者:User

標籤:bsp   lis   oid   exce   cond   except   row   new   ring   

package api;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.HBaseConfiguration;import org.apache.hadoop.hbase.client.HTable;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class PutExample {    public static void main(String[] args) throws IOException {        Configuration cfg = HBaseConfiguration.create();        HTable hTable = new HTable(cfg,"xyj");        Put put =new Put(Bytes.toBytes("r3"));        //fam qulifier value        put.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual1"),Bytes.toBytes("val1"));        put.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual2"),Bytes.toBytes("val2"));        put.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual3"),Bytes.toBytes("val3"));        hTable.put(put);    }}//hbase(main):001:0> create ‘xyj‘,‘cf1‘//hbase(main):004:0> put ‘xyj‘ ,‘r1‘,‘cf1:q1‘,‘v1‘//0 row(s) in 0.0160 seconds////hbase(main):005:0> put ‘xyj‘ ,‘r2‘,‘cf1:q2‘,‘v2‘//0 row(s) in 0.0100 seconds////hbase(main):006:0> put ‘xyj‘ ,‘r2‘,‘cf1:q3‘,‘v3‘//0 row(s) in 0.0160 seconds////hbase(main):007:0> list ‘xyj‘//TABLE                                                                                                                  //xyj                                                                                                                    //1 row(s) in 0.1330 seconds//hbase(main):009:0> scan ‘xyj‘//ROW                            COLUMN+CELL                                                                             // r1                            column=cf1:q1, timestamp=1511597241994, value=v1                                        // r2                            column=cf1:q2, timestamp=1511597275233, value=v2                                        // r2                            column=cf1:q3, timestamp=1511597290730, value=v3                                        // r3                            column=cf1:qual1, timestamp=1511597438929, value=val1                                   // r3                            column=cf1:qual2, timestamp=1511597438929, value=val2                                   // r3                            column=cf1:qual3, timestamp=1511597438929, value=val3                                   //3 row(s) in 0.0510 seconds

 

hbase-java-api001

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.