hindex 介绍
hindex 是华为公司开发的纯 Java 编写的 HBase 二级索引,兼容 Apache HBase 0.94.8。
当前的特性如下:
-
多个表索引
-
多个列索引
-
基于部分列值的索引
-
使用索引扫描等于和范围条件
-
批量加载数据来索引表(索引完成批量加载)
工作原理
HBase 二级索引是 100% 服务端实现的。
Put 操作
E.g.:
Table –> tab1 column family –> cf
Index –> idx1, cf1:c1 and idx2, cf1:c2
Index table –> tab1_idx (user table name with suffix “_idx” )
扫描操作
使用
IndexedHTableDescriptor htd = new IndexedHTableDescriptor(usertableName); IndexSpecification iSpec = new IndexSpecification(indexName); HColumnDescriptor hcd = new HColumnDescriptor(columnFamily); iSpec.addindexColumn(hcd, indexColumnQualifier, ValueType.String, 10); htd.addFamily(hcd); htd.addindex(iSpec); admin.createTable(htd);