In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
/ * * Delete all lines of RowKey * non-null judgment √ * / public static void deleteRows (String tablename,String RowKey) {HTable hull; 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 ("deleted successfully");} else {System.out.println ("piss off!") }} else {System.out.println ("table? Your watch! ") ;} catch (Exception e) {e.printStackTrace ();} finally {try {h.close ();} catch (IOException e) {e.printStackTrace () } / * * Delete the specified row of data * * / public static void deleteRow (String tablename,String RowKey,String family,String qualifier) {HTable hull; 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 ("deleted successfully!");} catch (IOException e) {e.printStackTrace ();} finally {try {h.close () } catch (IOException e) {e.printStackTrace ();} / * * query by condition (apply filter) * / @ SuppressWarnings ("deprecation") public static void GetByParam (String tablename,String Family,String qualifier,String value) {HTable hull; 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 ("Row cluster name value timestamp") 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 () } / * * query value * parameters by criteria: table name, row, column cluster, column name * / 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 ("start getting-beep beep"); 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 ("the value you want to check is" + new String (kv.getValue ();}} finally {table.close (); connection.close () }}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.