MapReduce服务 MRS-使用HBase过滤器Filter:代码样例
时间:2025-02-12 14:58:43
代码样例
以下代码片段在com.huawei.bigdata.hbase.examples包的“HBaseExample”类的testFilterList方法中。
样例代码获取方式请参考获取 MRS 应用开发样例工程。
代码样例:
public void testFilterList() { LOG .info("Entering testFilterList."); Table table = null; // Instantiate a ResultScanner object. ResultScanner rScanner = null; try { // Create the Configuration instance. table = conn.getTable(tableName); // Instantiate a Get object. Scan scan = new Scan(); scan.addColumn(Bytes.toBytes("info"), Bytes.toBytes("name")); // Instantiate a FilterList object in which filters have "and" // relationship with each other. FilterList list = new FilterList(Operator.MUST_PASS_ALL); // Obtain data with age of greater than or equal to 20. list.addFilter(new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("age"), CompareOp.GREATER_OR_EQUAL, Bytes.toBytes(new Long(20)))); // Obtain data with age of less than or equal to 29. list.addFilter(new SingleColumnValueFilter(Bytes.toBytes("info"), Bytes.toBytes("age"), CompareOp.LESS_OR_EQUAL, Bytes.toBytes(new Long(29)))); scan.setFilter(list); // Submit a scan request. rScanner = table.getScanner(scan); // Print query results. for (Result r = rScanner.next(); r != null; r = rScanner.next()) { for (Cell cell : r.rawCells()) { LOG.info(Bytes.toString(CellUtil.cloneRow(cell)) + ":" + Bytes.toString(CellUtil.cloneFamily(cell)) + "," + Bytes.toString(CellUtil.cloneQualifier(cell)) + "," + Bytes.toString(CellUtil.cloneValue(cell))); } } LOG.info("Filter list successfully."); } catch (IOException e) { LOG.error("Filter list failed ", e); } finally { if (rScanner != null) { // Close the scanner object. rScanner.close(); } if (table != null) { try { // Close the HTable object. table.close(); } catch (IOException e) { LOG.error("Close table failed ", e); } } } LOG.info("Exiting testFilterList.");}
support.huaweicloud.com/devg-mrs/mrs_06_0025.html
看了此文的人还看了
CDN加速
GaussDB
文字转换成语音
免费的服务器
如何创建网站
域名网站购买
私有云桌面
云主机哪个好
域名怎么备案
手机云电脑
SSL证书申请
云点播服务器
免费OCR是什么
电脑云桌面
域名备案怎么弄
语音转文字
文字图片识别
云桌面是什么
网址安全检测
网站建设搭建
国外CDN加速
SSL免费证书申请
短信批量发送
图片OCR识别
云数据库MySQL
个人域名购买
录音转文字
扫描图片识别文字
OCR图片识别
行驶证识别
虚拟电话号码
电话呼叫中心软件
怎么制作一个网站
Email注册网站
华为VNC
图像文字识别
企业网站制作
个人网站搭建
华为云计算
免费租用云托管
云桌面云服务器
ocr文字识别免费版
HTTPS证书申请
图片文字识别转换
国外域名注册商
使用免费虚拟主机
云电脑主机多少钱
鲲鹏云手机
短信验证码平台
OCR图片文字识别
SSL证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格
推荐文章
- MapReduce服务_如何使用MapReduce服务_MRS集群客户端安装与使用
- 大数据分析是什么_使用MapReduce_创建MRS服务
- MapReduce服务_什么是MapReduce服务_什么是HBase
- 什么是Spark_如何使用Spark_Spark的功能是什么
- Couchbase镜像下载
- MapReduce服务_什么是HetuEngine_如何使用HetuEngine
- MapReduce服务_什么是Hue_如何使用Hue
- MapReduce服务_什么是Kafka_如何使用Kafka
- MapReduce服务_什么是Loader_如何使用Loader
- MapReduce服务_什么是Flume_如何使用Flume
ServerLess102