当前位置: 首页 > wzjs >正文

内蒙古住房与城乡建设部网站wordpress页面连接

内蒙古住房与城乡建设部网站,wordpress页面连接,如何做淘宝客的网站,wordpress 注册体验Hbase布隆过滤器 小白的Hbase学习笔记 目录 Hbase布隆过滤器 1.过滤表中所有Value中 >23 的内容 2.获取表中age列大于23的所有RowKey值(1的改进) 3.比较以某个Value值开头的列 4.按前缀 准确值 后缀查找 5.获取RowKey中包含15001000的所有RowKe…

Hbase布隆过滤器

 

小白的Hbase学习笔记

 

目录

Hbase布隆过滤器

1.过滤表中所有Value中 >23 的内容

2.获取表中age列大于23的所有RowKey值(1的改进)

3.比较以某个Value值开头的列

4.按前缀 准确值 后缀查找

5.获取RowKey中包含15001000的所有RowKey(速度更快)

6.过滤列族名称以2结尾的RowKey数据

7.获取列名称以 na 开头的所有RowKey

8.对学生表中的信息进行过滤 条件有:1.所有性别为男性 2.所有文科班 3.年龄大于23岁


 

 

1.过滤表中所有Value中 >23 的内容

 

package com.shujia.comparator;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.ValueFilter;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
//过滤器/*** 需求:*      过滤表中所有Value中 >23 的内容*/
public class Code01ComparatorValue {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();/*** (CompareOp valueCompareOp, ByteArrayComparable valueComparator)*///创建字节比较器 参数传入具体比较的值BinaryComparator binaryComparator = new BinaryComparator(Bytes.toBytes("23"));//该过滤器是针对于当前表中所有的值进行过滤 只要满足则返回一行 并且 如果不满足返回NULL//put 'jan:tbl1','1001','info:name','25'ValueFilter filter = new ValueFilter(CompareFilter.CompareOp.GREATER, binaryComparator);//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

f0282c04f2904319bb0e74d546dff6be.png

 

2.获取表中age列大于23的所有RowKey值(1的改进)

 

package com.shujia.comparator;//需求:获取表中age列大于23的所有RowKey值
//01的改进代码
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.filter.ValueFilter;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class Code02ComparatorSingleColumns {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();/*** 单列过滤器:*      用于过滤单列值*      返回的数据是满足条件的所有RowKey*注意:*      如果一条RowKey用于比较的列不存在 那么该RowKey也会被返回*/SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("info"),Bytes.toBytes("age"),CompareFilter.CompareOp.GREATER,Bytes.toBytes(23));//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

7ea09daf85aa4d1dadf297030478f205.png

 

3.比较以某个Value值开头的列

 

package com.shujia.comparator;//该比较器用于比较以某个Value值开头的列
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class Code03ComparatorSingleColumns {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();/*** 单列过滤器:*      用于过滤单列值*      返回的数据是满足条件的所有RowKey*注意:*      如果一条RowKey用于比较的列不存在 那么该RowKey也会被返回*/SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("info"),Bytes.toBytes("clazz"),CompareFilter.CompareOp.EQUAL,//该比较器用于比较以某个Value值开头的列new BinaryPrefixComparator(Bytes.toBytes("文科")));//二进制前缀比较器//new BinaryPrefixComparator(Bytes.toBytes("文科六")));//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

ef74e68da6c94770832e84981bd86e28.png

 

4.按前缀 准确值 后缀查找

 

package com.shujia.comparator;//需求:获取RowKey中包含15001000的所有RowKeyimport org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class Code04ComparatorRowKey {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();RowFilter filter = new RowFilter(CompareFilter.CompareOp.EQUAL//RowKey中的值以15001000为开头的, new BinaryPrefixComparator(Bytes.toBytes("15001000"))//如果我们想按照准确的信息查找//, new BinaryComparator(Bytes.toBytes("1500100001"))//通过RegexStringComparator的正则表达式过滤以98为结尾的内容//,new RegexStringComparator(".*02$"));//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

5186a1be27c34841a2566f46ff27918a.png

9f8f375e23be46229ff14d2663e76ac4.png

ab1bb63ab91a44f1b098712ecbd7d0a3.png

 

5.获取RowKey中包含15001000的所有RowKey(速度更快)

 

package com.shujia.comparator;//需求:获取RowKey中包含15001000的所有RowKeyimport org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class Code05ComparatorPrefix {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();/***相比于在RowFilter中添加 BinaryComparator(Bytes.toBytes("15001000"))* PrefixFilter 执行速度更快 效率更高*/PrefixFilter filter = new PrefixFilter(Bytes.toBytes("15001000"));//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

366b349d6c1f48cc843d7e4087a927a2.png

 

6.过滤列族名称以2结尾的RowKey数据

 

package com.shujia.comparator;//需求:获取RowKey中包含15001000的所有RowKeyimport org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
import java.util.List;//需求:
//      过滤列族名称以2结尾的RowKey数据public class Code06ComparatorFamily {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();FamilyFilter filter = new FamilyFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator(".*2$"));//desc 'jan:tbl1'//添加列族 alter 'jan:tbl1',{NAME => 'info2',VERSIONS => 1}//put 'jan:tbl1','1001','info2:name','zhangsan'//put 'jan:tbl1','1002','info2:name','zhangsan'//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {List<Cell> cells = result.listCells();String rowKey = Bytes.toString(result.getRow());for (Cell cell : cells) {String family = Bytes.toString(CellUtil.cloneFamily(cell));String qualifier = Bytes.toString(CellUtil.cloneQualifier(cell));String value = Bytes.toString(CellUtil.cloneValue(cell));System.out.println(rowKey+","+family+","+qualifier+","+value);}}table.close();conn.close();}
}

777e78c120504c22bc4ae37f4a419678.png

81fccb2343df47c69dd2746208ca6a69.png

 

7.获取列名称以 na 开头的所有RowKey

 

package com.shujia.comparator;//需求:获取RowKey中包含15001000的所有RowKeyimport org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
import java.util.List;//需求:
//      获取列名称以 na 开头的所有RowKeypublic class Code07ComparatorColumns {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();ColumnPrefixFilter filter = new ColumnPrefixFilter(Bytes.toBytes("na"));//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {List<Cell> cells = result.listCells();String rowKey = Bytes.toString(result.getRow());for (Cell cell : cells) {String family = Bytes.toString(CellUtil.cloneFamily(cell));String qualifier = Bytes.toString(CellUtil.cloneQualifier(cell));String value = Bytes.toString(CellUtil.cloneValue(cell));System.out.println(rowKey+","+family+","+qualifier+","+value);}}table.close();conn.close();}
}

061408d885614570bf897193e01647a3.png

 

8.对学生表中的信息进行过滤 条件有:1.所有性别为男性 2.所有文科班 3.年龄大于23岁

 

package com.shujia.comparator;//需求:
//      对学生表中的信息进行过滤 条件有:1.所有性别为男性 2.所有文科班 3.年龄大于23岁import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
import java.util.ArrayList;
import java.util.List;//需求:
//      获取列名称以 na 开头的所有RowKeypublic class Code08Comparator {public static void main(String[] args) throws IOException {Configuration conf = new Configuration();conf.set("hbase.zookeeper.quorum","node1,node2,master");Connection conn = ConnectionFactory.createConnection(conf);Table table = conn.getTable(TableName.valueOf("jan:tbl1"));Scan scan=new Scan();//1.所有性别为男性SingleColumnValueFilter filter1 = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("gender"), CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes("男")));//2.所有文科班SingleColumnValueFilter filter2 = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("clazz"), CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes("文科")));//3.年龄大于23岁SingleColumnValueFilter filter3 = new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("age"), CompareFilter.CompareOp.GREATER, new BinaryPrefixComparator(Bytes.toBytes("23")));List<Filter> filters = new ArrayList<>();filters.add(filter1);filters.add(filter2);filters.add(filter3);FilterList filter = new FilterList(filters);//设置过滤器scan.setFilter(filter);//获取扫描器对象ResultScanner scanner = table.getScanner(scan);for (Result result : scanner) {String rowKey = Bytes.toString(result.getRow());String name = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")));String age = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("age")));String gender = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("gender")));String clazz = Bytes.toString(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("clazz")));System.out.println(rowKey+","+name+","+age+","+gender+","+clazz);}table.close();conn.close();}
}

d5cfd5c8ceb1469ba28f08696c50e95a.png

 

 

 


文章转载自:

http://JaqSp5C0.xfLwq.cn
http://Ztdie0j3.xfLwq.cn
http://CcdItxpO.xfLwq.cn
http://h34zYguS.xfLwq.cn
http://UPdgdnzl.xfLwq.cn
http://raJXYiTg.xfLwq.cn
http://Df3S3YV3.xfLwq.cn
http://bBWPMLbv.xfLwq.cn
http://r9y8cDjT.xfLwq.cn
http://VweSPSY1.xfLwq.cn
http://BTc6F0CX.xfLwq.cn
http://W96jZ8MY.xfLwq.cn
http://sKDcrntf.xfLwq.cn
http://IijkG7uD.xfLwq.cn
http://TKOrSgEs.xfLwq.cn
http://5MLJEJ4v.xfLwq.cn
http://bA37NTZm.xfLwq.cn
http://wNNtffvJ.xfLwq.cn
http://2w0HGU5l.xfLwq.cn
http://GP1EXzh5.xfLwq.cn
http://ZqxVlwAc.xfLwq.cn
http://zUL5iWRC.xfLwq.cn
http://GmyIcSVU.xfLwq.cn
http://Xr4q6heD.xfLwq.cn
http://BRzOsNhh.xfLwq.cn
http://0J94R3sj.xfLwq.cn
http://jrtlu0AK.xfLwq.cn
http://kbzun5yI.xfLwq.cn
http://bDj1vi39.xfLwq.cn
http://R0Huzo8o.xfLwq.cn
http://www.dtcms.com/wzjs/639065.html

相关文章:

  • 茶叶外贸网站建设wordpress2017备案号
  • 如何创建旅游网站广东东莞免费网站制作公司
  • 哪些网站可以做任务挣钱网站自然优化
  • html5手机网站织梦模板怎么做移动端网站计算像素
  • 如何使用模板网站建设网页鹏牛网做网站怎么样
  • 做淘宝客要建网站吗网站服务设计
  • 织梦音乐网站程序淘宝网页设计图片
  • 网站开发中期检查苏州园区人才市场
  • 网站展示重点广州建立公司网站多少钱
  • 怎么免费给自己建网站网站后台被百度蜘蛛抓取
  • 自己做图片网站php做的购物网站系统下载
  • 乡村旅游网站建设的意义开封府景点网站及移动端建设情况
  • 收费报名网站怎么做工作总结个人
  • 建设电子商务网站需要什么设备网站建设需要会什么软件有哪些方面
  • 彩票网站制作开发如果网站没有做icp备案吗
  • 网站开发产品设计公司网站建设项目采购合同
  • 建设网站需要哪个语言编译器内网电脑做网站服务器
  • 深圳苍松大厦 网站建设校园微网站建设
  • 英文网站上海网站建设 paiky
  • 购物网站建设特色美容院网站建设
  • 选择锦州网站建设wordpress 文字背景颜色
  • 简单做动画的网站wordpress oss cdn
  • 4在线做网站如果做淘宝网站
  • 怎样建设购物网站住房和城乡建设部监理工程师网站
  • 网站建设及使用方案山东省建设工程网站
  • 可信网站查询官网网站班级文化建设
  • 淮滨网站建设公司wordpress po翻译
  • php网站建设实例网站专业建设公司
  • 网站建设 的类型有哪些方面电脑软件商店
  • 优秀网站优点军事热点最新情况