Java Code Examples for org.apache.hadoop.hbase.client.Delete#deleteFamilyVersion()

The following examples show how to use org.apache.hadoop.hbase.client.Delete#deleteFamilyVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    tx = null;
    changeSets.clear();
  }
}
 
Example 2
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    try {
      hTable.flushCommits();
    } catch (Exception e) {
      LOG.error("Could not flush HTable commits", e);
    }
    tx = null;
    changeSets.clear();
  }
}
 
Example 3
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    tx = null;
    changeSets.clear();
  }
}
 
Example 4
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    try {
      hTable.flushCommits();
    } catch (Exception e) {
      LOG.error("Could not flush HTable commits", e);
    }
    tx = null;
    changeSets.clear();
  }
}
 
Example 5
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    try {
      hTable.flushCommits();
    } catch (Exception e) {
      LOG.error("Could not flush HTable commits", e);
    }
    tx = null;
    changeSets.clear();
  }
}
 
Example 6
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    tx = null;
    changeSets.clear();
  }
}
 
Example 7
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean doRollback() throws Exception {
  try {
    // pre-size arraylist of deletes
    int size = 0;
    for (Set<ActionChange> cs : changeSets.values()) {
      size += cs.size();
    }
    List<Delete> rollbackDeletes = new ArrayList<>(size);
    for (Map.Entry<Long, Set<ActionChange>> entry : changeSets.entrySet()) {
      long transactionTimestamp = entry.getKey();
      for (ActionChange change : entry.getValue()) {
        byte[] row = change.getRow();
        byte[] family = change.getFamily();
        byte[] qualifier = change.getQualifier();
        Delete rollbackDelete = new Delete(row);
        makeRollbackOperation(rollbackDelete);
        switch (conflictLevel) {
          case ROW:
          case NONE:
            // issue family delete for the tx write pointer
            rollbackDelete.deleteFamilyVersion(change.getFamily(), transactionTimestamp);
            break;
          case COLUMN:
            if (family != null && qualifier == null) {
              rollbackDelete.deleteFamilyVersion(family, transactionTimestamp);
            } else if (family != null && qualifier != null) {
              rollbackDelete.deleteColumn(family, qualifier, transactionTimestamp);
            }
            break;
          default:
            throw new IllegalStateException("Unknown conflict detection level: " + conflictLevel);
        }
        rollbackDeletes.add(rollbackDelete);
      }
    }
    hTable.delete(rollbackDeletes);
    return true;
  } finally {
    try {
      hTable.flushCommits();
    } catch (Exception e) {
      LOG.error("Could not flush HTable commits", e);
    }
    tx = null;
    changeSets.clear();
  }
}