use of io.cdap.cdap.data2.util.hbase.DeleteBuilder in project cdap by caskdata.
the class HBaseTable method undo.
@Override
protected void undo(NavigableMap<byte[], NavigableMap<byte[], Update>> persisted) throws Exception {
if (persisted.isEmpty()) {
return;
}
// NOTE: we use Delete with the write pointer as the specific version to delete.
List<Delete> deletes = Lists.newArrayList();
for (Map.Entry<byte[], NavigableMap<byte[], Update>> row : persisted.entrySet()) {
DeleteBuilder delete = tableUtil.buildDelete(row.getKey());
delete.setAttribute(TX_MAX_LIFETIME_MILLIS_KEY, txMaxLifetimeMillis);
for (Map.Entry<byte[], Update> column : row.getValue().entrySet()) {
// we want support tx and non-tx modes
if (tx != null) {
delete.setAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY, new byte[0]);
// TODO: hijacking timestamp... bad
delete.deleteColumn(columnFamily, column.getKey(), tx.getWritePointer());
} else {
delete.deleteColumns(columnFamily, column.getKey());
}
}
deletes.add(delete.build());
}
if (!deletes.isEmpty()) {
hbaseDelete(deletes);
}
}
use of io.cdap.cdap.data2.util.hbase.DeleteBuilder in project cdap by caskdata.
the class HBaseMetricsTable method delete.
@Override
public void delete(byte[] row, byte[][] columns) {
byte[] distributedKey = createDistributedRowKey(row);
DeleteBuilder delete = tableUtil.buildDelete(distributedKey);
for (byte[] column : columns) {
delete.deleteColumns(columnFamily, column);
}
try {
table.delete(delete.build());
} catch (IOException e) {
throw new DataSetException("Delete failed on table " + tableId, e);
}
}
use of io.cdap.cdap.data2.util.hbase.DeleteBuilder in project cdap by caskdata.
the class HBaseMetricsTable method delete.
@Override
public void delete(byte[] row, byte[][] columns) {
byte[] distributedKey = createDistributedRowKey(row);
DeleteBuilder delete = tableUtil.buildDelete(distributedKey);
for (byte[] column : columns) {
delete.deleteColumns(columnFamily, column);
}
try {
hTable.delete(delete.build());
} catch (IOException e) {
throw new DataSetException("Delete failed on table " + tableId, e);
}
}
use of io.cdap.cdap.data2.util.hbase.DeleteBuilder in project cdap by caskdata.
the class HBaseTable method undo.
@Override
protected void undo(NavigableMap<byte[], NavigableMap<byte[], Update>> persisted) throws Exception {
if (persisted.isEmpty()) {
return;
}
// NOTE: we use Delete with the write pointer as the specific version to delete.
List<Delete> deletes = Lists.newArrayList();
for (Map.Entry<byte[], NavigableMap<byte[], Update>> row : persisted.entrySet()) {
DeleteBuilder delete = tableUtil.buildDelete(row.getKey());
delete.setAttribute(TX_MAX_LIFETIME_MILLIS_KEY, txMaxLifetimeMillis);
for (Map.Entry<byte[], Update> column : row.getValue().entrySet()) {
// we want support tx and non-tx modes
if (tx != null) {
delete.setAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY, new byte[0]);
// TODO: hijacking timestamp... bad
delete.deleteColumn(columnFamily, column.getKey(), tx.getWritePointer());
} else {
delete.deleteColumns(columnFamily, column.getKey());
}
}
deletes.add(delete.build());
}
if (!deletes.isEmpty()) {
hbaseDelete(deletes);
}
}
Aggregations