[31/50] [abbrv] hbase git commit: HBASE-16381 Shell deleteall command should support row key prefixes (Yi Liang)
HBASE-16381 Shell deleteall command should support row key prefixes (Yi Liang) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1d6c90b4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1d6c90b4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1d6c90b4 Branch: refs/heads/hbase-12439 Commit: 1d6c90b4969b8ec47699c69984be052050a9ee46 Parents: 8ef6c76 Author: chenhengAuthored: Thu Sep 15 19:18:47 2016 +0800 Committer: chenheng Committed: Thu Sep 15 19:20:29 2016 +0800 -- hbase-shell/src/main/ruby/hbase/table.rb| 81 +++- .../src/main/ruby/shell/commands/deleteall.rb | 17 +++- hbase-shell/src/test/ruby/hbase/table_test.rb | 12 +++ 3 files changed, 86 insertions(+), 24 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/1d6c90b4/hbase-shell/src/main/ruby/hbase/table.rb -- diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 5930c0d..22bbcfe 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -160,6 +160,62 @@ EOF end #-- +# Create a Delete mutation +def _createdelete_internal(row, column = nil, +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + temptimestamp = timestamp + if temptimestamp.kind_of?(Hash) +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + end + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) + if temptimestamp.kind_of?(Hash) +temptimestamp.each do |k, v| + if v.kind_of?(String) +set_cell_visibility(d, v) if v + end +end + end + if args.any? + visibility = args[VISIBILITY] + set_cell_visibility(d, visibility) if visibility + end + if column +family, qualifier = parse_column_name(column) +d.addColumns(family, qualifier, timestamp) + end + return d +end + + #-- +# Delete rows using prefix +def _deleterows_internal(row, column = nil, +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args={}) + cache = row["CACHE"] ? row["CACHE"] : 100 + prefix = row["ROWPREFIXFILTER"] + + # create scan to get table names using prefix + scan = org.apache.hadoop.hbase.client.Scan.new + scan.setRowPrefixFilter(prefix.to_java_bytes) + # Run the scanner to get all rowkeys + scanner = @table.getScanner(scan) + # Create a list to store all deletes + list = java.util.ArrayList.new + # Iterate results + iter = scanner.iterator + while iter.hasNext +row = iter.next +key = org.apache.hadoop.hbase.util.Bytes::toStringBinary(row.getRow) +d = _createdelete_internal(key, column, timestamp, args) +list.add(d) +if list.size >= cache + @table.delete(list) + list.clear +end + end + @table.delete(list) +end + + #-- # Delete a cell def _delete_internal(row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) @@ -175,27 +231,12 @@ EOF if is_meta_table? raise ArgumentError, "Row Not Found" if _get_internal(row).nil? end - temptimestamp = timestamp - if temptimestamp.kind_of?(Hash) - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP - end - d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) - if temptimestamp.kind_of?(Hash) - temptimestamp.each do |k, v| - if v.kind_of?(String) - set_cell_visibility(d, v) if v - end -end - end - if args.any? - visibility = args[VISIBILITY] - set_cell_visibility(d, visibility) if visibility - end - if column -family, qualifier = parse_column_name(column) -d.addColumns(family, qualifier, timestamp) + if row.kind_of?(Hash) +_deleterows_internal(row, column, timestamp, args) + else +d = _createdelete_internal(row, column, timestamp, args) +@table.delete(d) end - @table.delete(d) end #--
hbase git commit: HBASE-16381 Shell deleteall command should support row key prefixes (Yi Liang)
Repository: hbase Updated Branches: refs/heads/master 8ef6c7634 -> 1d6c90b49 HBASE-16381 Shell deleteall command should support row key prefixes (Yi Liang) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1d6c90b4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1d6c90b4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1d6c90b4 Branch: refs/heads/master Commit: 1d6c90b4969b8ec47699c69984be052050a9ee46 Parents: 8ef6c76 Author: chenhengAuthored: Thu Sep 15 19:18:47 2016 +0800 Committer: chenheng Committed: Thu Sep 15 19:20:29 2016 +0800 -- hbase-shell/src/main/ruby/hbase/table.rb| 81 +++- .../src/main/ruby/shell/commands/deleteall.rb | 17 +++- hbase-shell/src/test/ruby/hbase/table_test.rb | 12 +++ 3 files changed, 86 insertions(+), 24 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/1d6c90b4/hbase-shell/src/main/ruby/hbase/table.rb -- diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 5930c0d..22bbcfe 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -160,6 +160,62 @@ EOF end #-- +# Create a Delete mutation +def _createdelete_internal(row, column = nil, +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + temptimestamp = timestamp + if temptimestamp.kind_of?(Hash) +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP + end + d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) + if temptimestamp.kind_of?(Hash) +temptimestamp.each do |k, v| + if v.kind_of?(String) +set_cell_visibility(d, v) if v + end +end + end + if args.any? + visibility = args[VISIBILITY] + set_cell_visibility(d, visibility) if visibility + end + if column +family, qualifier = parse_column_name(column) +d.addColumns(family, qualifier, timestamp) + end + return d +end + + #-- +# Delete rows using prefix +def _deleterows_internal(row, column = nil, +timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args={}) + cache = row["CACHE"] ? row["CACHE"] : 100 + prefix = row["ROWPREFIXFILTER"] + + # create scan to get table names using prefix + scan = org.apache.hadoop.hbase.client.Scan.new + scan.setRowPrefixFilter(prefix.to_java_bytes) + # Run the scanner to get all rowkeys + scanner = @table.getScanner(scan) + # Create a list to store all deletes + list = java.util.ArrayList.new + # Iterate results + iter = scanner.iterator + while iter.hasNext +row = iter.next +key = org.apache.hadoop.hbase.util.Bytes::toStringBinary(row.getRow) +d = _createdelete_internal(key, column, timestamp, args) +list.add(d) +if list.size >= cache + @table.delete(list) + list.clear +end + end + @table.delete(list) +end + + #-- # Delete a cell def _delete_internal(row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) @@ -175,27 +231,12 @@ EOF if is_meta_table? raise ArgumentError, "Row Not Found" if _get_internal(row).nil? end - temptimestamp = timestamp - if temptimestamp.kind_of?(Hash) - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP - end - d = org.apache.hadoop.hbase.client.Delete.new(row.to_s.to_java_bytes, timestamp) - if temptimestamp.kind_of?(Hash) - temptimestamp.each do |k, v| - if v.kind_of?(String) - set_cell_visibility(d, v) if v - end -end - end - if args.any? - visibility = args[VISIBILITY] - set_cell_visibility(d, visibility) if visibility - end - if column -family, qualifier = parse_column_name(column) -d.addColumns(family, qualifier, timestamp) + if row.kind_of?(Hash) +_deleterows_internal(row, column, timestamp, args) + else +d = _createdelete_internal(row, column, timestamp, args) +@table.delete(d) end - @table.delete(d) end