public void removeSingleElement(Object key, Element value) { final Delete delete = new Delete(ByteArraySerializer.fromObject(key)); delete.deleteColumns(Bytes.toBytes(VALUES), (byte[]) value.getId()); try { backingTable.delete(delete); } catch (IOException e) { LOG.severe("Cannot delete from backing table"); e.printStackTrace(); } }
@Override public Set<Element> remove(Object key) { Delete del = new Delete(ByteArraySerializer.fromObject(key)); try { backingTable.delete(del); } catch (IOException e) { LOG.severe("Error while deleting from table"); e.printStackTrace(); } return null; }
/** * Deletes the specified table with all its columns. ATTENTION: Invoking this method will delete * the table if it exists and therefore causes data loss. */ @Override public void clearStorage() throws StorageException { HBaseAdmin adm = getAdminInterface(); try { // first of all, check if table exists, if not - we are done if (!adm.tableExists(tableName)) { logger.debug("clearStorage() called before table {} was created, skipping.", tableName); return; } } catch (IOException e) { throw new TemporaryStorageException(e); } HTable table = null; try { table = new HTable(hconf, tableName); Scan scan = new Scan(); scan.setBatch(100); scan.setCacheBlocks(false); scan.setCaching(2000); ResultScanner scanner = null; try { scanner = table.getScanner(scan); for (Result res : scanner) { table.delete(new Delete(res.getRow())); } } finally { IOUtils.closeQuietly(scanner); } } catch (IOException e) { throw new TemporaryStorageException(e); } finally { IOUtils.closeQuietly(table); } }