コード例 #1
0
  public static void deleteTest(String tableStr) {
    try {
      Configuration conf = HBaseConfiguration.create();
      byte[] tableName = Bytes.toBytes(tableStr);

      HConnection hConnection = HConnectionManager.createConnection(conf);
      HTableInterface table = hConnection.getTable(tableName);

      byte[] startRow = Bytes.toBytes("rowKey_1");
      byte[] stopRow = Bytes.toBytes("rowKey_3");
      byte[] family = f0;

      Scan scan = new Scan();
      scan.addFamily(family);
      scan.setMaxVersions(1);

      //            scan.setStartRow(startRow);
      //            scan.setStopRow(stopRow);

      ResultScanner scanner = table.getScanner(scan);
      Result result = scanner.next();
      List<Delete> delete = new ArrayList<Delete>();
      while (result != null) {
        Delete del = new Delete(result.getRow());
        delete.add(del);
        result = scanner.next();
      }
      table.delete(delete);
      System.out.println("delete done");
      table.close(); // very important
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see com.hazelcast.core.MapStore#delete(java.lang.Object)
  */
 @Override
 public void delete(String key) {
   if (allowDelete) {
     HTableInterface table = null;
     try {
       Delete d = new Delete(Bytes.toBytes(key));
       table = pool.getTable(tableName);
       table.delete(d);
     } catch (IOException e) {
       LOG.error("IOException while deleting key: " + key, e);
     } finally {
       if (table != null) {
         pool.putTable(table);
       }
     }
   }
 }
コード例 #3
0
 /*
  * (non-Javadoc)
  *
  * @see com.hazelcast.core.MapStore#deleteAll(java.util.Collection)
  */
 @Override
 public void deleteAll(Collection<String> keys) {
   if (allowDelete) {
     HTableInterface table = null;
     try {
       List<Delete> deletes = new ArrayList<Delete>();
       for (String k : keys) {
         Delete d = new Delete(Bytes.toBytes(k));
         deletes.add(d);
       }
       table = pool.getTable(tableName);
       table.delete(deletes);
     } catch (IOException e) {
       LOG.error("IOException while deleting values", e);
     } finally {
       if (table != null) {
         pool.putTable(table);
       }
     }
   }
 }
コード例 #4
0
 @Override
 public void delete(List<Delete> deletes) throws IOException {
   table.delete(deletes);
 }
コード例 #5
0
 @Override
 public void delete(Delete delete) throws IOException {
   table.delete(delete);
 }