You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2020/05/07 17:26:51 UTC
[hbase] branch branch-2.3 updated: HBASE-24335 Support deleteall
with ts but without column in shell mode (#1668)
This is an automated email from the ASF dual-hosted git repository.
wchevreuil pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new 9dd8c96 HBASE-24335 Support deleteall with ts but without column in shell mode (#1668)
9dd8c96 is described below
commit 9dd8c9607c8135b9fd5a81f80ed2700c55ab893c
Author: bsglz <18...@qq.com>
AuthorDate: Fri May 8 01:18:57 2020 +0800
HBASE-24335 Support deleteall with ts but without column in shell mode (#1668)
Signed-off-by: Wellington Chevreuil <wc...@apache.org>
(cherry picked from commit 2cafe81e9c25c79ad9cf9498140ee01d449558df)
---
hbase-shell/src/main/ruby/hbase/table.rb | 14 ++++++++------
hbase-shell/src/main/ruby/shell/commands/deleteall.rb | 4 ++++
hbase-shell/src/test/ruby/hbase/table_test.rb | 11 +++++++++++
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb
index 2526ceb..3d489db 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -183,12 +183,14 @@ EOF
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 f18fa05..56f6d55 100644
--- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
@@ -30,12 +30,16 @@ row key prefix. Examples:
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
diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb
index 2ac03e5..0eef017 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 @@ module Hbase
@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 @@ module Hbase
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')