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
This commit is contained in:
larsh 2011-12-08 23:01:08 +00:00
parent c1ae21cc93
commit 14a266fb6c
3 changed files with 16 additions and 2 deletions

View File

@ -43,6 +43,7 @@ module HBaseConstants
STOPROW = "STOPROW" STOPROW = "STOPROW"
STARTROW = "STARTROW" STARTROW = "STARTROW"
ENDROW = STOPROW ENDROW = STOPROW
RAW = "RAW"
LIMIT = "LIMIT" LIMIT = "LIMIT"
METHOD = "METHOD" METHOD = "METHOD"
MAXLENGTH = "MAXLENGTH" MAXLENGTH = "MAXLENGTH"

View File

@ -218,10 +218,11 @@ module Hbase
startrow = args["STARTROW"] || '' startrow = args["STARTROW"] || ''
stoprow = args["STOPROW"] stoprow = args["STOPROW"]
timestamp = args["TIMESTAMP"] timestamp = args["TIMESTAMP"]
columns = args["COLUMNS"] || args["COLUMN"] || get_all_columns columns = args["COLUMNS"] || args["COLUMN"] || []
cache = args["CACHE_BLOCKS"] || true cache = args["CACHE_BLOCKS"] || true
versions = args["VERSIONS"] || 1 versions = args["VERSIONS"] || 1
timerange = args[TIMERANGE] timerange = args[TIMERANGE]
raw = args["RAW"] || false
# Normalize column names # Normalize column names
columns = [columns] if columns.class == String columns = [columns] if columns.class == String
@ -254,6 +255,7 @@ module Hbase
scan.setCacheBlocks(cache) scan.setCacheBlocks(cache)
scan.setMaxVersions(versions) if versions > 1 scan.setMaxVersions(versions) if versions > 1
scan.setTimeRange(timerange[0], timerange[1]) if timerange scan.setTimeRange(timerange[0], timerange[1]) if timerange
scan.setRaw(raw)
else else
scan = org.apache.hadoop.hbase.client.Scan.new scan = org.apache.hadoop.hbase.client.Scan.new
end end
@ -335,7 +337,11 @@ module Hbase
end end
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 (maxlength != -1) ? val[0, maxlength] : val
end end

View File

@ -51,6 +51,13 @@ switches block caching for the scanner on (true) or off (false). By
default it is enabled. Examples: default it is enabled. Examples:
hbase> scan 't1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false} 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 EOF
end end