From 14a266fb6c5d6d7581b1b98d1aee7abc27555c6f Mon Sep 17 00:00:00 2001 From: larsh Date: Thu, 8 Dec 2011 23:01:08 +0000 Subject: [PATCH] HBASE-4981 add raw scan support to shell (Lars H) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1212178 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/ruby/hbase.rb | 1 + src/main/ruby/hbase/table.rb | 10 ++++++++-- src/main/ruby/shell/commands/scan.rb | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/ruby/hbase.rb b/src/main/ruby/hbase.rb index 460b6c4b623..2a4abcb2ed7 100644 --- a/src/main/ruby/hbase.rb +++ b/src/main/ruby/hbase.rb @@ -43,6 +43,7 @@ module HBaseConstants STOPROW = "STOPROW" STARTROW = "STARTROW" ENDROW = STOPROW + RAW = "RAW" LIMIT = "LIMIT" METHOD = "METHOD" MAXLENGTH = "MAXLENGTH" diff --git a/src/main/ruby/hbase/table.rb b/src/main/ruby/hbase/table.rb index 3341aa46707..6dcf47e697a 100644 --- a/src/main/ruby/hbase/table.rb +++ b/src/main/ruby/hbase/table.rb @@ -218,10 +218,11 @@ module Hbase startrow = args["STARTROW"] || '' stoprow = args["STOPROW"] timestamp = args["TIMESTAMP"] - columns = args["COLUMNS"] || args["COLUMN"] || get_all_columns + columns = args["COLUMNS"] || args["COLUMN"] || [] cache = args["CACHE_BLOCKS"] || true versions = args["VERSIONS"] || 1 timerange = args[TIMERANGE] + raw = args["RAW"] || false # Normalize column names columns = [columns] if columns.class == String @@ -254,6 +255,7 @@ module Hbase scan.setCacheBlocks(cache) scan.setMaxVersions(versions) if versions > 1 scan.setTimeRange(timerange[0], timerange[1]) if timerange + scan.setRaw(raw) else scan = org.apache.hadoop.hbase.client.Scan.new end @@ -335,7 +337,11 @@ module Hbase end end - val = "timestamp=#{kv.getTimestamp}, value=#{org.apache.hadoop.hbase.util.Bytes::toStringBinary(kv.getValue)}" + if kv.isDelete + val = "timestamp=#{kv.getTimestamp}, type=#{org.apache.hadoop.hbase.KeyValue::Type::codeToType(kv.getType)}" + else + val = "timestamp=#{kv.getTimestamp}, value=#{org.apache.hadoop.hbase.util.Bytes::toStringBinary(kv.getValue)}" + end (maxlength != -1) ? val[0, maxlength] : val end diff --git a/src/main/ruby/shell/commands/scan.rb b/src/main/ruby/shell/commands/scan.rb index 378bd6c3153..e58aaaceb8e 100644 --- a/src/main/ruby/shell/commands/scan.rb +++ b/src/main/ruby/shell/commands/scan.rb @@ -51,6 +51,13 @@ switches block caching for the scanner on (true) or off (false). By default it is enabled. Examples: hbase> scan 't1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false} + +Also for experts, there is an advanced option -- RAW -- which instructs the +scanner to return all cells (including delete markers and uncollected deleted +cells). This option cannot be combined with requesting specific COLUMNS. +Disabled by default. Example: + + hbase> scan 't1', {RAW => true, VERSIONS => 10} EOF end