Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-24335 Support deleteall with ts but without column in shell mode #1668

Merged
merged 5 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -183,12 +183,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