Skip to content

Commit

Permalink
HBASE-24335 Support deleteall with ts but without column in shell mode (
Browse files Browse the repository at this point in the history
apache#1668)

Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
(cherry picked from commit 2cafe81)
  • Loading branch information
bsglz authored and meiyi committed Jul 10, 2020
1 parent 41ccdab commit 5df4ec2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
14 changes: 8 additions & 6 deletions hbase-shell/src/main/ruby/hbase/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ def _createdelete_internal(row, column = nil,
visibility = args[VISIBILITY]
set_cell_visibility(d, visibility) if visibility
end
if column && all_version
family, qualifier = parse_column_name(column)
d.addColumns(family, qualifier, timestamp)
elsif column && !all_version
family, qualifier = parse_column_name(column)
d.addColumn(family, qualifier, timestamp)
if column != ""
if column && all_version
family, qualifier = parse_column_name(column)
d.addColumns(family, qualifier, timestamp)
elsif column && !all_version
family, qualifier = parse_column_name(column)
d.addColumn(family, qualifier, timestamp)
end
end
d
end
Expand Down
4 changes: 4 additions & 0 deletions hbase-shell/src/main/ruby/shell/commands/deleteall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ def help
hbase> deleteall 't1', 'r1'
hbase> deleteall 't1', 'r1', 'c1'
hbase> deleteall 't1', 'r1', 'c1', ts1
//'' means no specific column, will delete all cells in the row which timestamp is lower than
//the one specified in the command
hbase> deleteall 't1', 'r1', '', ts1
hbase> deleteall 't1', 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
ROWPREFIXFILTER can be used to delete row ranges
hbase> deleteall 't1', {ROWPREFIXFILTER => 'prefix'}
hbase> deleteall 't1', {ROWPREFIXFILTER => 'prefix'}, 'c1' //delete certain column family in the row ranges
hbase> deleteall 't1', {ROWPREFIXFILTER => 'prefix'}, 'c1', ts1
hbase> deleteall 't1', {ROWPREFIXFILTER => 'prefix'}, '', ts1
hbase> deleteall 't1', {ROWPREFIXFILTER => 'prefix'}, 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
CACHE can be used to specify how many deletes batched to be sent to server at one time, default is 100
Expand Down
11 changes: 11 additions & 0 deletions hbase-shell/src/test/ruby/hbase/table_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def setup
@test_table.put(105, "x:a", "3")
@test_table.put(105, "x:a", "4")

@test_table.put(106, "x:a", "3", 1588765900000)
@test_table.put(106, "x:b", "4", 1588765900010)

@test_table.put("111", "x:a", "5")
@test_table.put("111", "x:b", "6")
@test_table.put("112", "x:a", "5")
Expand Down Expand Up @@ -168,6 +171,14 @@ def teardown
assert_nil(res)
end

define_test "deleteall should work with timestamps but w/o columns" do
@test_table.deleteall("106", "", 1588765900005)
res = @test_table._get_internal('106', 'x:a')
assert_nil(res)
res = @test_table._get_internal('106', 'x:b')
assert_not_nil(res)
end

define_test "deleteall should work with integer keys" do
@test_table.deleteall(105)
res = @test_table._get_internal('105', 'x:a')
Expand Down

0 comments on commit 5df4ec2

Please sign in to comment.