我是靠谱客的博主 多情发箍,这篇文章主要介绍Hbase CRUD Operations(Java API),现在分享给大家,希望可以做个参考。

 Put Method

 

复制代码
1
void put(Put put)throws IOException

 

 Put的构造方法

 

复制代码
1
2
3
4
Put(byte[] row) Put(byte[] row,RowLock rowLock) Put(byte[] row,long ts) Put(byte[] row,long ts,RowLock rowLock)

 

 add()

 

复制代码
1
2
3
4
Put add(byte[] family,byte[] qualifier,byte[] value) Put add(byte[] family,byte[] qualifier,long ts,byte[] value) Put add(KeyValue kv)throws IOException

 Each call to add() specifies exactly one column,or,in combination with an optional timestamp,one single cell.

 

原子操作

复制代码
1
2
boolean checkAndPut(Bytes.toBytes("item"), Bytes.toBytes("happy"), Bytes.toBytes("live"), null, put1)
 

 

 

delete()

 

复制代码
1
2
3
4
void delete(Delete delete)throws IOException Delete(byte[] row) Delete(byte[] row,long timestamp,RowLock rowLock)

原子操作

复制代码
1
2
boolean checkAndDelete(byte[] row,byte[] family,byte[] qualifier,byte[] value,Delete delete)throws IOException
 

 

 

复制代码
1
2
3
4
5
6
7
8
9
Delete deleteFamily(byte[] family) Delete deleteFamily(byte[] family,long timestamp)//the timestamp matches the same and all older versions of all columns Delete deleteColumns(byte[] family,byte[] qualifier) Delete deleteColumns(byte[] family,byte[] qualifier,long timestamp) Delete deleteColumn(byte[] family,byte[] qualifier) Delete deleteColumn(byte[] family,byte[] qualifier,long timestamp) void setTimestamp(long timestamp)
 

 

 

 

 

 

get()

 

复制代码
1
2
3
List<KeyValue> get(byte[] family,byte[] qualifier) Map<byte[] ,List<KeyValue>>getFamilyMap()

 

 

复制代码
1
2
3
4
5
6
7
Get addFamily(byte[] family) Get addColumn(byte[] family,byte[] qualifier) Get setTimeRange(long minStamp,long maxStamp)throws IOException Get setTimeStamp(long timestamp) Get setMaxVersions() Get setMaxVersions(int maxVersions)throws IOException
 

 

 

 

has()

 

复制代码
1
2
3
4
boolean has(byte[]family,byte[] qualifier) boolean has(byte[]family,byte[] qualifier,long ts) boolean has(byte[]family,byte[] qualifier,byte[] value) boolean has(byte[]family,byte[] qualifier,long ts,byte[] value)
 

 

Example

 

 

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class PutExample{ public static void main(String[] args)throws IOException { Configuration conf= HBaseConfiguration.create();//hbase-default.xml and hbase-site.xml HTable table= newHTable(conf,"testtable"); Put put= new Put(Bytes.toBytes("row1")); //org.apache.hadoop.hbase.util.Bytes put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes("val1")); put.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"), Bytes.toBytes("val2")); table.put(put); } }
 

 

 

最后

以上就是多情发箍最近收集整理的关于Hbase CRUD Operations(Java API)的全部内容,更多相关Hbase内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部