读书人

Hadoop系列之学习札记(一)

发布时间: 2012-11-17 11:14:15 作者: rapoo

Hadoop系列之学习笔记(一)
HBase学习笔记(一)
1.HTable是HBase与用户接口交互的最核心的类.
org.apache.hadoop.hbase.client.HTable
2.HTable-->HTablePool
3.Bytes Class的常用方法有
1).byte[] toBytes(String s);
2).byte[] toBytes(boolean b);
3).byte[] toBytes(Long l);
4).String toString(final byte [] b);
5).static long toLong(byte[] bytes);
4.Put Class
构造时一般需要指定具体的行Key
5.HTable-->put(Put put)-->Put Class-->RowKey
6.HBaseConfiguration继承于Configuration
1).在初始化会根据系统配置找到hbase-default.xml与hbase-site.xml这二个文件并加载。
2).在加载文件后,可以通过config.set("属性名","值")来修改相关配置。
7.查询行的各版本
$hbase>scan 'test',{VERSIONS=>3}
系统默认只记录最近三次的版本(timestamp)内容.
8.KeyValue Class 有三个重要参数getFamily(),getQualifier(),getTimestamp()
描述了具体的数据模型。
9.HTable默认AutoFlush=true,可以修改为false,与之对应的方法是isAutoFlush(),flushCommits()
10.HTable中的put方法,可以直接put list内容,代码:
List<Put> puts=new ArrayList<Put>();
hTable.put(puts);
11.Get Class 示例代码:
Get aGet = new Get(Bytes.toBytes("1"));
aGet.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("列名"));
Result result = hTable.get(aGet);
12.Result Class 查询结果
13.Result result.getMap();取得数据集内的信息,包括Family,Qualifier,Timestamp内的内容;
14.result.getNoVersionMap();不包含版本信息的,相对结构要简单一些。

部分示例代码:
构造内容:



读书人网 >行业软件

热点推荐