您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 本溪分类信息网,免费分类信息发布

Hbase ValueFilter

2025/1/3 1:52:28发布12次查看
hbase valuefilter用于过滤值 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;impo
hbase valuefilter用于过滤值
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.filter;import org.apache.hadoop.hbase.filter.substringcomparator;import org.apache.hadoop.hbase.filter.valuefilter;import org.apache.hadoop.hbase.util.bytes;public class testhbasevaluefilter { string tablename = test_value_filter; configuration config = hbaseconfiguration.create(); /** * 部分代码来自hbase权威指南 * * @throws ioexception */ public void testfilter() throws ioexception { htable table = new htable(config, tablename); scan scan = new scan(); system.out.println(只列出值包含data1的列); filter filter1 = new valuefilter(comparefilter.compareop.equal, new substringcomparator(data1)); 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 valuefilter, 感谢原作者分享。

本溪分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录