hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-12268 Add support for Scan.setRowPrefixFilter to shell (Niels Basjes)
Date Tue, 06 Jan 2015 19:16:47 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 26e3e1b30 -> f57a9f5bd


HBASE-12268 Add support for Scan.setRowPrefixFilter to shell (Niels Basjes)


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

Branch: refs/heads/master
Commit: f57a9f5bd509a7e532723d0b0e4c97032a3d5482
Parents: 26e3e1b
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Jan 6 11:16:39 2015 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jan 6 11:16:39 2015 -0800

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase.rb              |  1 +
 hbase-shell/src/main/ruby/hbase/table.rb        |  4 ++++
 .../src/main/ruby/shell/commands/scan.rb        |  8 ++++----
 .../main/ruby/shell/commands/set_visibility.rb  |  6 +++---
 hbase-shell/src/test/ruby/hbase/table_test.rb   | 20 ++++++++++++++++++++
 5 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f57a9f5b/hbase-shell/src/main/ruby/hbase.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase.rb b/hbase-shell/src/main/ruby/hbase.rb
index 5928e7b..a857bd9 100644
--- a/hbase-shell/src/main/ruby/hbase.rb
+++ b/hbase-shell/src/main/ruby/hbase.rb
@@ -42,6 +42,7 @@ module HBaseConstants
   METADATA = org.apache.hadoop.hbase.HConstants::METADATA
   STOPROW = "STOPROW"
   STARTROW = "STARTROW"
+  ROWPREFIXFILTER = "ROWPREFIXFILTER"
   ENDROW = STOPROW
   RAW = "RAW"
   LIMIT = "LIMIT"

http://git-wip-us.apache.org/repos/asf/hbase/blob/f57a9f5b/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 b408649..94922bb 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -411,6 +411,7 @@ EOF
         filter = args["FILTER"]
         startrow = args["STARTROW"] || ''
         stoprow = args["STOPROW"]
+        rowprefixfilter = args["ROWPREFIXFILTER"]
         timestamp = args["TIMESTAMP"]
         columns = args["COLUMNS"] || args["COLUMN"] || []
         # If CACHE_BLOCKS not set, then default 'true'.
@@ -435,6 +436,9 @@ EOF
           org.apache.hadoop.hbase.client.Scan.new(startrow.to_java_bytes)
         end
 
+        # This will overwrite any startrow/stoprow settings
+        scan.setRowPrefixFilter(rowprefixfilter.to_java_bytes) if rowprefixfilter
+
         columns.each do |c| 
           family, qualifier = parse_column_name(c.to_s)
           if qualifier

http://git-wip-us.apache.org/repos/asf/hbase/blob/f57a9f5b/hbase-shell/src/main/ruby/shell/commands/scan.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/scan.rb b/hbase-shell/src/main/ruby/shell/commands/scan.rb
index 8ce8d46..da4dace 100644
--- a/hbase-shell/src/main/ruby/shell/commands/scan.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/scan.rb
@@ -24,8 +24,8 @@ module Shell
         return <<-EOF
 Scan a table; pass table name and optionally a dictionary of scanner
 specifications.  Scanner specifications may include one or more of:
-TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, TIMESTAMP, MAXLENGTH,
-or COLUMNS, CACHE
+TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, ROWPREFIXFILTER, TIMESTAMP,
+MAXLENGTH or COLUMNS, CACHE
 
 If no columns are specified, all columns will be scanned.
 To scan all members of a column family, leave the qualifier empty as in
@@ -44,8 +44,8 @@ Some examples:
   hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}
   hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804, 1303668904]}
   hbase> scan 't1', {REVERSED => true}
-  hbase> scan 't1', {FILTER => "(PrefixFilter ('row2') AND
-    (QualifierFilter (>=, 'binary:xyz'))) AND (TimestampsFilter ( 123, 456))"}
+  hbase> scan 't1', {ROWPREFIXFILTER => 'row2', FILTER => "
+    (QualifierFilter (>=, 'binary:xyz')) AND (TimestampsFilter ( 123, 456))"}
   hbase> scan 't1', {FILTER =>
     org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
   hbase> scan 't1', {CONSISTENCY => 'TIMELINE'}

http://git-wip-us.apache.org/repos/asf/hbase/blob/f57a9f5b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
index cdb7724..c8942a6 100644
--- a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
+++ b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb
@@ -24,7 +24,7 @@ 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
+of: TIMERANGE, FILTER, STARTROW, STOPROW, ROWPREFIXFILTER, 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
@@ -40,8 +40,8 @@ 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
+    hbase> set_visibility 't1', 'A&B&C', {ROWPREFIXFILTER => 'row2',
+        FILTER => "(QualifierFilter (>=, 'binary:xyz')) AND
         (TimestampsFilter ( 123, 456))"}
 
 This command will only affect existing cells and is expected to be mainly

http://git-wip-us.apache.org/repos/asf/hbase/blob/f57a9f5b/hbase-shell/src/test/ruby/hbase/table_test.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb
index fa2990d..9e4765f 100644
--- a/hbase-shell/src/test/ruby/hbase/table_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/table_test.rb
@@ -412,6 +412,26 @@ module Hbase
       assert_nil(res['2'])
     end
 
+    define_test "scan should support ROWPREFIXFILTER parameter (test 1)" do
+      res = @test_table._scan_internal ROWPREFIXFILTER => '1'
+      assert_not_nil(res)
+      assert_kind_of(Hash, res)
+      assert_not_nil(res['1'])
+      assert_not_nil(res['1']['x:a'])
+      assert_not_nil(res['1']['x:b'])
+      assert_nil(res['2'])
+    end
+
+    define_test "scan should support ROWPREFIXFILTER parameter (test 2)" do
+      res = @test_table._scan_internal ROWPREFIXFILTER => '2'
+      assert_not_nil(res)
+      assert_kind_of(Hash, res)
+      assert_nil(res['1'])
+      assert_not_nil(res['2'])
+      assert_not_nil(res['2']['x:a'])
+      assert_not_nil(res['2']['x:b'])
+    end
+
     define_test "scan should support LIMIT parameter" do
       res = @test_table._scan_internal LIMIT => 1
       assert_not_nil(res)


Mime
View raw message