HBASE-1682 IndexedRegion does not properly handle deletes

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@831473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-10-30 22:23:08 +00:00
parent b80f8587bf
commit d493073e54
2 changed files with 14 additions and 8 deletions

View File

@ -84,6 +84,8 @@ Release 0.21.0 - Unreleased
HBASE-1927 Scanners not closed properly in certain circumstances
HBASE-1934 NullPointerException in ClientScanner (Andrew Purtell via Stack)
HBASE-1946 Unhandled exception at regionserver (Dmitriy Lyfar via Stack)
HBASE-1682 IndexedRegion does not properly handle deletes
(Andrew McCall via Clint Morgan and Stack)
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -229,7 +229,7 @@ class IndexedRegion extends TransactionalRegion {
@Override
public void delete(Delete delete, final Integer lockid, boolean writeToWAL)
throws IOException {
// First remove the existing indexes.
if (!getIndexes().isEmpty()) {
// Need all columns
NavigableSet<byte[]> neededColumns = getColumnsForIndexes(getIndexes());
@ -251,13 +251,17 @@ class IndexedRegion extends TransactionalRegion {
for (IndexSpecification indexSpec : getIndexes()) {
removeOldIndexEntry(indexSpec, delete.getRow(), oldColumnValues);
}
}
super.delete(delete, lockid, writeToWAL);
// Handle if there is still a version visible.
if (delete.getTimeStamp() != HConstants.LATEST_TIMESTAMP) {
get.setTimeRange(1, delete.getTimeStamp());
oldRow = super.get(get, lockid);
SortedMap<byte[], byte[]> currentColumnValues = convertToValueMap(oldRow);
if (!getIndexes().isEmpty()) {
Get get = new Get(delete.getRow());
// Rebuild index if there is still a version visible.
Result currentRow = super.get(get, lockid);
if (!currentRow.isEmpty()) {
SortedMap<byte[], byte[]> currentColumnValues = convertToValueMap(currentRow);
for (IndexSpecification indexSpec : getIndexes()) {
if (IndexMaintenanceUtils.doesApplyToIndex(indexSpec, currentColumnValues)) {
updateIndex(indexSpec, delete.getRow(), currentColumnValues);
@ -265,7 +269,7 @@ class IndexedRegion extends TransactionalRegion {
}
}
}
super.delete(delete, lockid, writeToWAL);
}
private SortedMap<byte[], byte[]> convertToValueMap(Result result) {