From 3e727bec778899007052425435f9093f85a66795 Mon Sep 17 00:00:00 2001 From: chunhao Date: Fri, 4 Aug 2017 00:56:20 +0800 Subject: [PATCH] [HBASE-18142] Deletion of a cell deletes the previous versions too --- hbase-shell/src/main/ruby/hbase/table.rb | 23 +++++++++++++--------- hbase-shell/src/main/ruby/shell/commands/delete.rb | 2 +- .../src/main/ruby/shell/commands/deleteall.rb | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index b297f58..d745143 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -162,7 +162,7 @@ EOF #---------------------------------------------------------------------------------------------- # Create a Delete mutation def _createdelete_internal(row, column = nil, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}, is_all = true) temptimestamp = timestamp if temptimestamp.is_a?(Hash) timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP @@ -181,7 +181,11 @@ EOF end if column family, qualifier = parse_column_name(column) - d.addColumns(family, qualifier, timestamp) + if is_all + d.addColumns(family, qualifier, timestamp) + else + d.addColumn(family, qualifier, timestamp) + end end d end @@ -189,7 +193,7 @@ EOF #---------------------------------------------------------------------------------------------- # Delete rows using prefix def _deleterows_internal(row, column = nil, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}, is_all = true) cache = row['CACHE'] ? row['CACHE'] : 100 prefix = row['ROWPREFIXFILTER'] @@ -205,7 +209,7 @@ EOF while iter.hasNext row = iter.next key = org.apache.hadoop.hbase.util.Bytes.toStringBinary(row.getRow) - d = _createdelete_internal(key, column, timestamp, args) + d = _createdelete_internal(key, column, timestamp, args, is_all) list.add(d) if list.size >= cache @table.delete(list) @@ -218,23 +222,24 @@ EOF #---------------------------------------------------------------------------------------------- # Delete a cell def _delete_internal(row, column, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) - _deleteall_internal(row, column, timestamp, args) + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}, is_all = true) + + _deleteall_internal(row, column, timestamp, args, is_all) end #---------------------------------------------------------------------------------------------- # Delete a row def _deleteall_internal(row, column = nil, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}, is_all = true) # delete operation doesn't need read permission. Retaining the read check for # meta table as a part of HBASE-5837. if is_meta_table? raise ArgumentError, 'Row Not Found' if _get_internal(row).nil? end if row.is_a?(Hash) - _deleterows_internal(row, column, timestamp, args) + _deleterows_internal(row, column, timestamp, args, is_all) else - d = _createdelete_internal(row, column, timestamp, args) + d = _createdelete_internal(row, column, timestamp, args, is_all) @table.delete(d) end end diff --git a/hbase-shell/src/main/ruby/shell/commands/delete.rb b/hbase-shell/src/main/ruby/shell/commands/delete.rb index 3e4447c..923d349 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete.rb @@ -48,7 +48,7 @@ EOF def delete(table, row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) @start_time = Time.now - table._delete_internal(row, column, timestamp, args) + table._delete_internal(row, column, timestamp, args, false) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index f5444ae..f18fa05 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -58,7 +58,7 @@ EOF def deleteall(table, row, column = nil, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) @start_time = Time.now - table._deleteall_internal(row, column, timestamp, args) + table._deleteall_internal(row, column, timestamp, args, true) end end end -- 1.9.2.msysgit.0