按条件查询与删除数据-----HBase(伪分布)学习笔记
发表于:2025-11-06 作者:千家信息网编辑
千家信息网最后更新 2025年11月06日,/* * 删除RowKey所有行 * 非空判断√ */ public static void deleteRows(String tablename,String RowKey){
千家信息网最后更新 2025年11月06日按条件查询与删除数据-----HBase(伪分布)学习笔记
/* * 删除RowKey所有行 * 非空判断√ */ public static void deleteRows(String tablename,String RowKey){ HTable h=null; HBaseAdmin ha=null; Get get=new Get(Bytes.toBytes(RowKey)); try{ ha=new HBaseAdmin(config); if(ha.tableExists(tablename)){ h=new HTable(config,tablename); Delete d=new Delete(Bytes.toBytes(RowKey)); if(h.exists(get)){ h.delete(d); System.out.println("删除成功"); }else{ System.out.println("滚犊子!!!"); } }else{ System.out.println("表呢?你的表那!!"); } }catch(Exception e){ e.printStackTrace(); }finally{ try { h.close(); } catch (IOException e) { e.printStackTrace(); } } } /* * 删除指定一行的数据 * */ public static void deleteRow(String tablename,String RowKey,String family,String qualifier){ HTable h=null; try { h=new HTable(config,tablename); Delete d=new Delete(Bytes.toBytes(RowKey)); d.deleteColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier)); h.delete(d); System.out.println("删除成功!"); } catch (IOException e) { e.printStackTrace(); }finally{ try { h.close(); } catch (IOException e) { e.printStackTrace(); } } } /* * 按条件查询(应用filter) */ @SuppressWarnings("deprecation")public static void GetByParam(String tablename,String Family,String qualifier,String value){ HTable h=null; ResultScanner rs=null; try { h=new HTable(config,tablename); Filter f=new SingleColumnValueFilter(Bytes.toBytes(Family),Bytes.toBytes(qualifier),CompareOp.EQUAL,Bytes.toBytes(value) ); Scan scan=new Scan(); scan.setFilter(f); scan.addColumn(Bytes.toBytes(Family),Bytes.toBytes(qualifier)); rs=h.getScanner(scan); System.out.println("行 列簇 列名 值 时间戳"); for (Result r : rs) { for (KeyValue kv : r.raw()) { System.out.println(kv.getRowOffset()+" "+Family+" "+qualifier+" "+new String(kv.getValue())+" "+ kv.getTimestamp()); } } } catch (IOException e) { e.printStackTrace(); }finally{ try{ rs.close(); h.close(); }catch(Exception e){ e.printStackTrace(); } } } /* * 按条件查询value * 参数:表名,行,列簇,列名 */ public static void get(String tablename,String rowKey,String Family,String qualifier)throws Exception{ HConnection connection = HConnectionManager.createConnection(config); HTableInterface table = connection.getTable(TableName.valueOf(tablename)); try { System.out.println("开始获取------哔哔哔"); Get get=new Get(rowKey.getBytes()); get.addColumn(Family.getBytes(), qualifier.getBytes()); Result r=table.get(get); for(KeyValue kv:r.raw()) { System.out.println("您要查的值为"+new String(kv.getValue())); } } finally { table.close(); connection.close(); } }
条件
查询
成功
数据
一行
参数
时间
犊子
应用
笔记
学习
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全的统一模型
登录到发送邮件服务器
青岛软件开发编程
中国云龙网络安全团队
夏季网络安全教育活动
怎么组装云桌面服务器
采集服务器信息
sql 数据库删除日志文件
重庆工控软件开发价格
网络安全在初中哪节课
数据库的命名规则必须遵循
实物模拟 数据库教具
lol匹配服务器连接不上
文档服务器api
马鞍山 软件开发
数据库crud
网络安全与微博监管的关系
深圳戴尔服务器
pc服务器配置
代办网络技术公司
网络安全重要性的探讨
互联网与科技创新解说脚本
企业级服务器销售价格
思科网络技术结束语
涉税网络安全
网络安全法关于数据备份
文档服务器api
计算机网络技术期末考试重点
软件开发年度计划实施方案
联想服务器北京代理