hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1589890 - in /hbase/trunk/hbase-shell/src/main/ruby: shell.rb shell/commands/set_visibility.rb
Date Thu, 24 Apr 2014 21:41:30 GMT
Author: apurtell
Date: Thu Apr 24 21:41:29 2014
New Revision: 1589890

URL: http://svn.apache.org/r1589890
Log:
HBASE-11002 Shell support for changing cell visibility for testing

Added:
    hbase/trunk/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
Modified:
    hbase/trunk/hbase-shell/src/main/ruby/shell.rb

Modified: hbase/trunk/hbase-shell/src/main/ruby/shell.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-shell/src/main/ruby/shell.rb?rev=1589890&r1=1589889&r2=1589890&view=diff
==============================================================================
--- hbase/trunk/hbase-shell/src/main/ruby/shell.rb (original)
+++ hbase/trunk/hbase-shell/src/main/ruby/shell.rb Thu Apr 24 21:41:29 2014
@@ -362,5 +362,6 @@ Shell.load_command_group(
     set_auths
     get_auths
     clear_auths
+    set_visibility
   ]
 )

Added: hbase/trunk/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb?rev=1589890&view=auto
==============================================================================
--- hbase/trunk/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb (added)
+++ hbase/trunk/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb Thu Apr 24 21:41:29
2014
@@ -0,0 +1,73 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Shell
+  module Commands
+    class SetVisibility < Command
+      def help
+        return <<-EOF
+Set the visibility expression on one or more existing cells.
+
+Pass table name, visibility expression, and a dictionary containing
+scanner specifications.  Scanner specifications may include one or more
+of: TIMERANGE, FILTER, STARTROW, STOPROW, TIMESTAMP, or COLUMNS
+
+If no columns are specified, all columns will be included.
+To include all members of a column family, leave the qualifier empty as in
+'col_family:'.
+
+The filter can be specified in two ways:
+1. Using a filterString - more information on this is available in the
+Filter Language document attached to the HBASE-4176 JIRA
+2. Using the entire package name of the filter.
+
+Examples:
+
+    hbase> set_visibility 't1', 'A|B', {COLUMNS => ['c1', 'c2']}
+    hbase> set_visibility 't1', '(A&B)|C', {COLUMNS => 'c1',
+        TIMERANGE => [1303668804, 1303668904]}
+    hbase> set_visibility 't1', 'A&B&C', {FILTER => "(PrefixFilter ('row2')
AND
+        (QualifierFilter (>=, 'binary:xyz'))) AND
+        (TimestampsFilter ( 123, 456))"}
+
+This command will only affect existing cells and is expected to be mainly
+useful for feature testing and functional verification.
+EOF
+      end
+
+      def command(table, visibility, scan)
+        t = table(table)
+        now = Time.now
+        scanner = t._get_scanner(scan)
+        count = 0
+        iter = scanner.iterator
+        while iter.hasNext
+          row = iter.next
+          row.list.each do |cell|
+            put = org.apache.hadoop.hbase.client.Put.new(row.getRow)
+            put.add(cell)
+            t.set_cell_visibility(put, visibility)
+            t.table.put(put)
+          end
+          count += 1
+        end
+        formatter.footer(now, count)
+      end
+
+    end
+  end
+end



Mime
View raw message