You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2014/07/09 08:14:13 UTC

git commit: HBASE-11088 Support Visibility Expression Deletes in Shell (Ram)

Repository: hbase
Updated Branches:
  refs/heads/master cec30fd8a -> eafa9f6c1


HBASE-11088 Support Visibility Expression Deletes in Shell (Ram)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/eafa9f6c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/eafa9f6c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/eafa9f6c

Branch: refs/heads/master
Commit: eafa9f6c1fabd60ae6cdcb5c6c14b075c4ccf46f
Parents: cec30fd
Author: Ramkrishna <ra...@intel.com>
Authored: Wed Jul 9 11:43:26 2014 +0530
Committer: Ramkrishna <ra...@intel.com>
Committed: Wed Jul 9 11:43:26 2014 +0530

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase/table.rb        | 23 +++++++++++++++++---
 .../src/main/ruby/shell/commands/delete.rb      | 12 ++++++----
 .../src/main/ruby/shell/commands/deleteall.rb   | 10 +++++----
 hbase-shell/src/main/ruby/shell/commands/put.rb |  2 +-
 4 files changed, 35 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/eafa9f6c/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 5f71070..14fe1e4 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -160,15 +160,32 @@ EOF
 
     #----------------------------------------------------------------------------------------------
     # Delete a cell
-    def _delete_internal(row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
-      _deleteall_internal(row, column, timestamp)
+    def _delete_internal(row, column, 
+    			timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
+      _deleteall_internal(row, column, timestamp, args)
     end
 
     #----------------------------------------------------------------------------------------------
     # Delete a row
-    def _deleteall_internal(row, column = nil, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
+    def _deleteall_internal(row, column = nil, 
+    		timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
       raise ArgumentError, "Row Not Found" if _get_internal(row).nil?
+      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.deleteColumns(family, qualifier, timestamp)

http://git-wip-us.apache.org/repos/asf/hbase/blob/eafa9f6c/hbase-shell/src/main/ruby/shell/commands/delete.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/delete.rb b/hbase-shell/src/main/ruby/shell/commands/delete.rb
index a0c50e3..dcb8341 100644
--- a/hbase-shell/src/main/ruby/shell/commands/delete.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/delete.rb
@@ -30,21 +30,25 @@ marked with the time 'ts1', do:
 
   hbase> delete 'ns1:t1', 'r1', 'c1', ts1
   hbase> delete 't1', 'r1', 'c1', ts1
+  hbase> delete 't1', 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
 
 The same command can also be run on a table reference. Suppose you had a reference
 t to table 't1', the corresponding command would be:
 
   hbase> t.delete 'r1', 'c1',  ts1
+  hbase> t.delete 'r1', 'c1',  ts1, {VISIBILITY=>'PRIVATE|SECRET'}
 EOF
       end
 
-      def command(table, row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
-        delete(table(table), row, column, timestamp)
+      def command(table, row, column, 
+      				timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
+        delete(table(table), row, column, timestamp, args)
       end
 
-      def delete(table, row, column, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
+      def delete(table, row, column, 
+      				timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
         format_simple_command do
-          table._delete_internal(row, column, timestamp)
+          table._delete_internal(row, column, timestamp, args)
         end
       end
     end

http://git-wip-us.apache.org/repos/asf/hbase/blob/eafa9f6c/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
index 197dbd4..e6118c9 100644
--- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb
@@ -29,6 +29,7 @@ a column and timestamp. Examples:
   hbase> deleteall 't1', 'r1'
   hbase> deleteall 't1', 'r1', 'c1'
   hbase> deleteall 't1', 'r1', 'c1', ts1
+  hbase> deleteall 't1', 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
 
 The same commands also can be run on a table reference. Suppose you had a reference
 t to table 't1', the corresponding command would be:
@@ -36,18 +37,19 @@ t to table 't1', the corresponding command would be:
   hbase> t.deleteall 'r1'
   hbase> t.deleteall 'r1', 'c1'
   hbase> t.deleteall 'r1', 'c1', ts1
+  hbase> t.deleteall 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
 EOF
       end
 
       def command(table, row, column = nil,
-                  timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
-        deleteall(table(table), row, column, timestamp)
+                  timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
+        deleteall(table(table), row, column, timestamp, args)
       end
 
       def deleteall(table, row, column = nil,
-                    timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP)
+                    timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {})
         format_simple_command do
-          table._deleteall_internal(row, column, timestamp)
+          table._deleteall_internal(row, column, timestamp, args)
         end
       end
     end

http://git-wip-us.apache.org/repos/asf/hbase/blob/eafa9f6c/hbase-shell/src/main/ruby/shell/commands/put.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/put.rb b/hbase-shell/src/main/ruby/shell/commands/put.rb
index 4879200..2b47a4d 100644
--- a/hbase-shell/src/main/ruby/shell/commands/put.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/put.rb
@@ -31,7 +31,7 @@ at row 'r1' under column 'c1' marked with the time 'ts1', do:
   hbase> put 't1', 'r1', 'c1', 'value', ts1
   hbase> put 't1', 'r1', 'c1', 'value', {ATTRIBUTES=>{'mykey'=>'myvalue'}}
   hbase> put 't1', 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
-  hbase> put 't1', 'r1', 'c1', 'value', ts1, {VISIBILITY=>'PRIVATE|SECRET'}}
+  hbase> put 't1', 'r1', 'c1', 'value', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
 
 The same commands also can be run on a table reference. Suppose you had a reference
 t to table 't1', the corresponding command would be: