MapReduce方式创建二级索引
使用整合MapReduce的方式创建hbase索引。主要的流程如下:
1.1扫描输入表,使用hbase继承类TableMapper
1.2获取rowkey和指定字段名称和字段值
1.3创建Put实例, value=rowkey, rowkey=columnName +"_" +columnValue
1.4使用IdentityTableReducer将数据写入索引表
1.1 继承TableMapper
GenerateIndexMapper继承TableMapper类
LoadIndexMapper类数据批量导入hbase
SecondIndexMain是驱动类
二级索引种类:
2.1创建单列索引
2.2同时创建多个单列索引
2.3创建联合索引(最多同时支持3个列)
2.4只根据rowkey创建索引