按条件查询与删除数据-----HBase(伪分布)学习笔记
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,/* * 删除RowKey所有行 * 非空判断√ */ public static void deleteRows(String tablename,String RowKey){
千家信息网最后更新 2026年10月31日按条件查询与删除数据-----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安全错误
数据库的锁怎样保障安全
华服互联网科技靠谱吗
互联网金融 科技
艾特科技互联网
远拓互联网科技
广州凡科互联网科技
润盈互联网科技
长亮科技互联网金融
一五八零互联网科技
广西拼得多互联网科技有限公司
上海电发互联网科技有限公司
湖南诚度互联网科技有限公司
宁夏科技产业互联网案例
福建科技产业互联网发展
四川慕妮娅互联网科技有限公司
山东子淼互联网科技有限公司
互联网第三次科技革命特征
江苏苏星互联网科技有限公司
世界互联网科技成果奖
江苏互联网智能科技产品出厂价
互联网科技职业技能培训学校
云南咖啡
科技类互联网
金融科技创新监管互联网金融
极限挑战互联网科技
互联网科技咨询
南通创西澳互联网科技有限公司
下一代互联网重大应用科技园
互联网金融运营模式中的金融科技
银川新华互联网科技学校原画
广州三三互联网科技有限公司