您好,欢迎访问一九零五行业门户网

Hbase QualifierFilter

hbase qualifierfilter用于过滤qualifier,也就是一个列族里面data:xxx,冒号后面的字符串。 =。= package com.fatkun.filter.comparison;import java.io.ioexception;import org.apache.hadoop.conf.configuration;import org.apache.hadoop.hbase.hbasecon
hbase qualifierfilter用于过滤qualifier,也就是一个列族里面data:xxx,冒号后面的字符串。 =。=
package com.fatkun.filter.comparison;import java.io.ioexception;import org.apache.hadoop.conf.configuration;import org.apache.hadoop.hbase.hbaseconfiguration;import org.apache.hadoop.hbase.hcolumndescriptor;import org.apache.hadoop.hbase.htabledescriptor;import org.apache.hadoop.hbase.client.get;import org.apache.hadoop.hbase.client.hbaseadmin;import org.apache.hadoop.hbase.client.htable;import org.apache.hadoop.hbase.client.put;import org.apache.hadoop.hbase.client.result;import org.apache.hadoop.hbase.client.resultscanner;import org.apache.hadoop.hbase.client.scan;import org.apache.hadoop.hbase.filter.binarycomparator;import org.apache.hadoop.hbase.filter.comparefilter;import org.apache.hadoop.hbase.filter.familyfilter;import org.apache.hadoop.hbase.filter.filter;import org.apache.hadoop.hbase.filter.qualifierfilter;import org.apache.hadoop.hbase.util.bytes;public class testhbasequalifierfilter { string tablename = test_qualifier_filter; configuration config = hbaseconfiguration.create(); /** * 部分代码来自hbase权威指南 * @throws ioexception */ public void testrowfilter() throws ioexception { htable table = new htable(config, tablename); scan scan = new scan(); system.out.println(只列出小于col5的列); filter filter1 = new qualifierfilter(comparefilter.compareop.less, new binarycomparator(bytes.tobytes(col5))); scan.setfilter(filter1); resultscanner scanner1 = table.getscanner(scan); for (result res : scanner1) { system.out.println(res); } scanner1.close(); system.out.println(get也可以设置filter); get get1 = new get(bytes.tobytes(row003)); get1.setfilter(filter1); result result1 = table.get(get1); system.out.println(result of get(): + result1); } /** * 初始化数据 */ public void init() { // 创建表和初始化数据 try { hbaseadmin admin = new hbaseadmin(config); if (!admin.tableexists(tablename)) { htabledescriptor htd = new htabledescriptor(tablename); hcolumndescriptor hcd1 = new hcolumndescriptor(data1); htd.addfamily(hcd1); hcolumndescriptor hcd2 = new hcolumndescriptor(data2); htd.addfamily(hcd2); hcolumndescriptor hcd3 = new hcolumndescriptor(data3); htd.addfamily(hcd3); admin.createtable(htd); } htable table = new htable(config, tablename); table.setautoflush(false); int count = 50; for (int i = 1; i 原文地址:hbase qualifierfilter, 感谢原作者分享。

其它类似信息

推荐信息