From 4567141887bf14864a96ea97405aba57d48bc459 Mon Sep 17 00:00:00 2001 From: bsglz <18031031@qq.com> Date: Wed, 6 May 2020 20:24:07 +0800 Subject: [PATCH 1/5] HBASE-24335 Support deleteall with ts but without column in shell mode --- hbase-shell/src/main/ruby/hbase/table.rb | 14 ++++++++------ .../src/main/ruby/shell/commands/deleteall.rb | 2 ++ hbase-shell/src/test/ruby/hbase/table_test.rb | 11 +++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 6df3652fad61..e3b64d6cc64c 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -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 diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index f18fa0550679..65f199129da3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -30,12 +30,14 @@ def help hbase> deleteall 't1', 'r1' hbase> deleteall 't1', 'r1', 'c1' hbase> deleteall 't1', 'r1', 'c1', ts1 + hbase> deleteall 't1', 'r1', '', ts1 //'' means not specify column 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 diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index 2ac03e50a7af..7b8a7b67e35d 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -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") @@ -168,6 +171,14 @@ def teardown assert_nil(res) end + define_test "deleteall should work 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') From 74f549ca3a61d30cef0fe588a75d124603047848 Mon Sep 17 00:00:00 2001 From: bsglz <18031031@qq.com> Date: Thu, 7 May 2020 09:41:29 +0800 Subject: [PATCH 2/5] fix review issue --- hbase-shell/src/main/ruby/shell/commands/deleteall.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index 65f199129da3..a2e927cd603c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -30,7 +30,9 @@ def help hbase> deleteall 't1', 'r1' hbase> deleteall 't1', 'r1', 'c1' hbase> deleteall 't1', 'r1', 'c1', ts1 - hbase> deleteall 't1', 'r1', '', ts1 //'' means not specify column + //'' means no specific column, it will deletes 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 From ae47979ab3239c37877a2ebd53367810e7e77aeb Mon Sep 17 00:00:00 2001 From: bsglz <18031031@qq.com> Date: Thu, 7 May 2020 10:47:56 +0800 Subject: [PATCH 3/5] fix describe of unit test --- hbase-shell/src/test/ruby/hbase/table_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index 7b8a7b67e35d..0eef0179b3f5 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -171,7 +171,7 @@ def teardown assert_nil(res) end - define_test "deleteall should work timestamps but w/o columns" do + 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) From ee5a2ab831459ac0926faf6370283a4600d12fa3 Mon Sep 17 00:00:00 2001 From: Zheng Wang <18031031@qq.com> Date: Thu, 7 May 2020 22:07:13 +0800 Subject: [PATCH 4/5] fix review issue --- hbase-shell/src/main/ruby/shell/commands/deleteall.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index a2e927cd603c..b21206f8f686 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -30,7 +30,7 @@ def help hbase> deleteall 't1', 'r1' hbase> deleteall 't1', 'r1', 'c1' hbase> deleteall 't1', 'r1', 'c1', ts1 - //'' means no specific column, it will deletes all cells in the row which timestamp is lower than + //'' means no specific column, will deletes 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'} From df1b7d1c71d1723eb02605df8915f4e750793f2a Mon Sep 17 00:00:00 2001 From: Zheng Wang <18031031@qq.com> Date: Thu, 7 May 2020 23:33:31 +0800 Subject: [PATCH 5/5] fix review issue --- hbase-shell/src/main/ruby/shell/commands/deleteall.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index b21206f8f686..56f6d5549a37 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -30,7 +30,7 @@ def help hbase> deleteall 't1', 'r1' hbase> deleteall 't1', 'r1', 'c1' hbase> deleteall 't1', 'r1', 'c1', ts1 - //'' means no specific column, will deletes all cells in the row which timestamp is lower than + //'' 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'}