From b91fb30a822a0081e120ef8af6b1183614f24afe Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Mon, 25 Apr 2011 17:09:05 +0000 Subject: [PATCH] HBASE-2470 Add Scan.setTimeRange() support in Shell git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1096523 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/main/ruby/hbase/table.rb | 2 ++ src/test/ruby/hbase/table_test.rb | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 812707cf086..1e165aba010 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -183,6 +183,7 @@ Release 0.91.0 - Unreleased HBASE-3609 Improve the selection of regions to balance; part 2 (Ted Yu) HBASE-2939 Allow Client-Side Connection Pooling (Karthik Sankarachary) HBASE-3798 [REST] Allow representation to elide row key and column key + HBASE-2470 Add Scan.setTimeRange() support in Shell (Harsh J Chouraria) TASKS HBASE-3559 Move report of split to master OFF the heartbeat channel diff --git a/src/main/ruby/hbase/table.rb b/src/main/ruby/hbase/table.rb index 387802de9e3..f4c2637e3d8 100644 --- a/src/main/ruby/hbase/table.rb +++ b/src/main/ruby/hbase/table.rb @@ -221,6 +221,7 @@ module Hbase columns = args["COLUMNS"] || args["COLUMN"] || get_all_columns cache = args["CACHE_BLOCKS"] || true versions = args["VERSIONS"] || 1 + timerange = args[TIMERANGE] # Normalize column names columns = [columns] if columns.class == String @@ -239,6 +240,7 @@ module Hbase scan.setTimeStamp(timestamp) if timestamp scan.setCacheBlocks(cache) scan.setMaxVersions(versions) if versions > 1 + scan.setTimeRange(timerange[0], timerange[1]) if timerange else scan = org.apache.hadoop.hbase.client.Scan.new end diff --git a/src/test/ruby/hbase/table_test.rb b/src/test/ruby/hbase/table_test.rb index ff197defc8d..5d56e18518e 100644 --- a/src/test/ruby/hbase/table_test.rb +++ b/src/test/ruby/hbase/table_test.rb @@ -369,6 +369,14 @@ module Hbase assert_not_nil(res['2']['x:b']) end + define_test "scan should support TIMERANGE parameter" do + res = @test_table.scan TIMERANGE => [0, 1] + assert_not_nil(res) + assert_kind_of(Hash, res) + assert_nil(res['1']) + assert_nil(res['2']) + end + define_test "scan should support COLUMNS parameter with an array of columns" do res = @test_table.scan COLUMNS => [ 'x:a', 'x:b' ] assert_not_nil(res)